Classy Coding

My Journey to Code

How to Use an API with Ruby

Leave a comment

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s