Want to implement APIs in Rails

Hi, I want to write APIs for my rails 3.1 application but have never
written an API ever. I am supposed to write REST and SOAP APIs. Is
there a formal book or e-book or screencasts or tutorials which
teaches about APIs in Rails and best practices?

I suggest you to read Rails 3 in Action book written by Ryan B. and

Get yourself a copy of Service Oriented Design with Ruby and rails

Read through this:
and read this:

Make sure that you support oauth2 if you need security. I had some
with this gem here: https://github.com/flowtown/rack-oauth2-server

In general I believe it is better to create a Sinatra rack app as part
your rails app that exposes the API, much cleaner that way. Use Json as
default transport.

As for Soap… avoid it like the plague if you can.

check out ActiveResource too –