Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails API Tutorial [closed]

I've never worked with or written an API before. To help me learn, I want to write a Facebook API library RubyGem.

I'm thinking I should start with learning how to write a simple API with RoR.

Do you know of any good resources or tutorials that will help me learn how to write an API with Ruby?

like image 256
ramz15 Avatar asked Oct 24 '11 05:10

ramz15


2 Answers

I think you'll first have to chose what is exactly that you want to learn, since there's quite a few parts to this.

A gem such as facebooker is used to consume the API of a web service rather than "create" or expose an API (for a web service). In order to understand a library like this and what it does, you could try to learn more about APIs in general, but also about ways to access them using Ruby.

Even though Rails and the Rails community are embracing RESTful (or actually RESTlike) APIs, there are a bunch of other forms around as well, such as SOAP. Facebook e.g. has ditched REST in favor of their graph API. Check the answers for this question, which deals with the different types, to learn more: Examples of the best SOAP/REST/RPC web APIs? And why do you like them? And what's wrong with them?

For ways to access (REST) APIs I'd suggest taking a closer look at the source code of gems such as e.g. HTTParty and rest-client as well as Ruby's standard library Net::HTTP.

What comes to API's and web services, I've heard good things about "Restful web services" but there's a whole bunch of books and about a gazillion blog posts out there on this topic. Google is your friend.

And then you'll probably want to have a look at the development of ruby gems in general. This answer might give you some pointers in this regard: Ruby : How to write a gem?

This is an endless topic and I suggest to just get started somewhere. Learn how APIs work, how to access them and then read lots and lots of source code, e.g. of Facebooker or one of the other Facebook API gems. See how they work and start writing code. Good luck!

like image 86
polarblau Avatar answered Oct 15 '22 00:10

polarblau


http://8raystech.com/2009/10/06/a-real-life-restful-rails-application

[edit]

The above link is broken.

like image 28
Artem Kalinchuk Avatar answered Oct 15 '22 01:10

Artem Kalinchuk