Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails API - Versionist vs Rocket Pants

Wondering if anyone has had any experiences with these gems?

  • Versionist
  • RocketPants

Or can you recommend a better one to help me add a restful API to my app?

Thanks.

like image 229
newcoder Avatar asked Dec 28 '22 00:12

newcoder


2 Answers

Here's a few to checkout:

Grape - A bit like Sinatra but for building APIs. Built on top of Rack with minimal dependencies.

Rocket Pants - A set of tools for building APIs alongside Rails, inspired by Grape but with deeper Rails and ActionPack integration

Rails::API - Rails minus the stuff not needed for building apis.

I used Grape on a few projects, and I found it pretty good for small to medium APIs, especially if you want to add an API on top of an existing rails app, prefer a clean separation from your rails controllers and still be able to share model logic between the two.

It's like Sinatra which means defining endpoints is straight-forward and flexible, which can be a good or bad thing. On bigger APIs things can get a bit messy if you're not disciplined.

In comparison Rocket Pants is a little bit more opinionated, which gives you more structure and out of the box features. With Grape, as your API grows, you will need to find a way to refactor and structure the code yourself.

like image 133
sai Avatar answered Jan 06 '23 18:01

sai


There's a bunch of information on this topic on RailsCast:

  • RABL
  • The Rails API Gem
  • REST API Versioning
  • Securing an API
like image 40
dom Avatar answered Jan 06 '23 18:01

dom