Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Right place to make call to external API

Hello I'm learning ruby on rails. After reading in treehouse blog about httparty I was wondering, what is the right place to make API call.

I was searching in Google my question, but couldn't find answer. Some say in controller, others model, but from this post I thought I should make it in lib folder?

here is the blog post about httparty http://blog.teamtreehouse.com/its-time-to-httparty

1 Answer

Hi Janis,

If you are interesting to know more about latest "Build a Rails API" course which is still under development by our staffs.

Build a Rails API - it will hopefully release March 2015

-Salman

I'm sorry if I wasn't clear or asked my question incorrectly, but I wanted to know more about how to get info from API. Lets say I would like to find pictures in flickr and show them in my rails app. To do that I would have to make GET request to flickr API. And I wanted to know what is the correct place (in model/controller/lib or make new folder under app directory) to make this GET request from my rails app to flickr API.

Thanks for showing this course I hope to see it soon.

Okay, I get your points. As I am aware that we don't have Ruby API for Flickr at this moment, however, one place I know we have is Ajax and APIs for Flickr in one of our track, please see last section.

I will contact our team to find more info about Ruby API, right now we can use to follow this instruction pretty straightforward - Integrating Flickr into your rails website.

Hope that helps. :-)

Salman Akram Thanks for showing this gem. But now I'm confused, why should I use httparty if I can use flickr gem?

Janis,

I just give you different options to use APIs and many gems for Flickr. The best way I can suggest is to wait new course (latest updates) in March, basically I don't have good answer why we use httparty rather than other flickr gems.

Salman Akram Ok. Thank you for quick response. I will wait for the new course :)

Awesome, I myself can't wait for it. ;)

~Happy Coding!