Classy Coding

My Journey to Code


Leave a comment

How to Use an API with Ruby

This past week I learned how to use an API with Ruby! It is amazingly easy so here are the steps.

Step 1.

Go to  http://rdoc.info  or https://www.ruby-toolbox.com/ to search for the API. Both sources are reliable and have an extensive collection with documentation. Searching for your gem is so easy!

Step 2.

For ruby-toolbox, this is how your screen will look. This gives you information regarding the gem version, release date, bug tracker, pretty much all the info you could possibly want. Then it gives you the github link as well as the rdoc link.

Image

Step 3.

When you click on the Rubygem, you be taken to this page https://rubygems.org/gems/twitter This gives you instructions on installing the gem. Pretty easy so far!

Step 4.

The documentation link (this link appears on both screens at step 2 and 3) re-directs you to the rdoc page that explains in detail the functions available to you with this gem.

This includes further installation instructions:

Image

a quick start guide (with a link to registering your application so you don’t have to search around for that!):

Image

….and the best part gives you usage examples that are INCREDIBLY helpful. This allows you to see all the methods available to you while using this gem. Pretty awesome!

Image

Step 5.

After installing the gem, registering your application with Twitter, finish configuring with the authentication codes you received during registration. Follow the configuration format provided in the quickstart section listed previously. Don’t forget to require your gem in your ruby document.

Step 6.

That’s it! You are set up with the Twitter API gem. This instructions can easily work with any API you are hoping to use in your ruby code.

Advertisements


Leave a comment

Completed My First Hackathon!

This past weekend I completed my first hackathon at MakerSquare.

Check out my group’s app at: tweet-o-phone.herokuapp.com 

The app is basically like a game of telephone through Twitter and Giphy. You give a word then Tweet-o-Phone searches Twitter for a tweet with that word. Then takes that tweet and chooses a random word from it to give to Giphy. The ouput is a hilarious gif that may or may not be related to your original search….so fun to see how things get translated through social media. 

We used the Twitter and Giphy Ruby gems. I have to say that the gems make it really easy to access the data you need. It was a blast!