I've been tasked to create a mobile application as well as an accompanying website. Both the application and website will interact with the same database. To make things easy, I figure creating an API would be best that way I can separate it out from the mobile application and website.

Would this be the preferable method? I'm thinking Sinatra would be best for this situation. I'm using Ruby on Rails for the website but feel it would be overkill for the API.

I just want to validate my thoughts regarding this issue.


  • Couldn't you simply use rails "format" feature ? This allows you to return plain html for web browser and only data formatted in json or xml to mobile application that uses the API. Application and browser would use same URL, but the first one with /controller/action/id.xml and the second with the usual /controller/action/id.html (for example)
    – David
    Sep 21, 2011 at 6:57
  • This is pretty much the most ideal use case for Sinatra I can think of. The API part anyway.
    – Rig
    Aug 25, 2013 at 3:44

3 Answers 3


If you're already using Rails, there's isn't much gain in running Sinatra as well. To skip the Rails goodness and get a performance boost, use Metal to serve your API requests.


Benchmark! If you find yourself adding lots of stuff back in just to make it work, you might chew through the performance boost and more.


Also have a look at padrino. It is built on top of Sinatra and adds much of the goodness of Rails but without the magic.

Many people love the simplicity and expressiveness of Sinatra but quickly come to miss a great deal of functionality provided by other web frameworks such as Rails when building non-trivial applications.

Our goal with Padrino is to stay true to the core principles of Sinatra while at the same time creating a standard library of tools, helpers and functions that will make Sinatra suitable for increasingly complex applications...


Actually Sinatra itself recommends using it as middleware, e.g. for rails applications.

So I'm guessing it's more a question of which you are most familiar with, Sinatra would be a lightweight approach, but rails could work, too. Choose the one you're most familiar with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.