ruby

Rundown on Grape Related Articles

My journey on API development started last year when I had to develop an API for a startup that I was involved with. Since then I’ve been intensively studying it through reading lots of articles and books. I built my first API using Java, even though it’s not my favorite language. To be honest, these days I’ve been shying away from projects where Java is the main language, however it was a great experience because I was able to learn lots of good practices for creating RESTful APIs.

And what’s my favorite language? If you’re following me on Twitter, you know that it’s Ruby. It was about three years ago when I was first introduced to Ruby, and since then I’ve been using it for most of my projects. Why Ruby? Because it’s the most elegant and beautiful language ever created. The worst thing about being a Ruby enthusiast is that everybody thinks you’re a Rails expert. I’m not. In fact, I have never used Rails.

Having said that, you might be wondering what I’ve been using to create my APIs. The answer is Grape: a simple and straightforward DSL that enormously simplifies the API developer’s life. This is not a step-by-step article on how to create APIs using Grape. Instead, I’m going to briefly lay out and comment on some articles and blog posts I’ve came across during these last months. I’m really surprised by the fact that there are only a few articles about Grape available on the Internet, and this is my motivation for writing this post.


Official Grape’s Site
https://github.com/intridea/grape

You haven’t ever heard of Grape? Then the first thing you should read is its official documentation. Every article I’m going to list from this point forward will be based on the assumption that you already know how to set up your Ruby and Grape environments. For this reason, it’s really important that you start reading it first if you’re new to this world. The documentation is simple and easy to understand.


Introduction to building APIs with Grape
http://codetunes.com/2014/introduction-to-building-apis-with-grape/

If you’ve already gotten the hang of programming in Ruby, and you know how to install Grape, then it’s time to read more specific and detailed articles. This one was published by Codetunes and describes how they built their API using Grape. It’s a good article despite the fact that they’re using some conventions that I personally don’t like, such as putting the API versioning information into the URI.

You must take into account, however, that they’re using Grape alongside Rails. Still, it’s not mandatory, and in my opinion you shouldn’t do this if the API which you’re planning to build doesn’t require all of the features and resources provided by Rails.


Build REST APIs with Grape
http://code.tutsplus.com/courses/build-rest-apis-with-grape

It’s a series of fourteen video lessons explaining how to build REST APIs with Grape. I haven’t watched every lesson, but it seems to be a very detailed step-by-step tutorial. Unfortunately, they provide only the first two videos for free.


Building RESTful API using Grape in Rails
http://funonrails.com/2014/03/building-restful-api-using-grape-in-rails/

A simple but useful article written by Sandip. Sandip doesn’t waste your time with misleading concepts and unnecessary explanations on how Grape works. He dives into the code in the first lines of his article. Again, take into account that he’s using Grape alongside Rails.


The 10 Minute API: Getting an API Up and Running in 10 Minutes with 3scale, Grape and Heroku
http://www.3scale.net/2012/06/the-10-minute-api-up-running-3scale-grape-heroku-api-10-minutes/

This is a 10 minutes hands-on video explaining how to build and deploy Grape based APIs on Heroku, one of the leading cloud host solutions on the market. I have some APIs running there and I strongly recommend their services. And no, they’re not paying me to write this, ok? 🙂

 The last thing worth mentioning about this article is the fact that they’re using their own API Management solution to authenticate each API call. Have you ever heard of the term API Management? I won’t explain it in this post because it deserves its own article. Instead, take a look at this article.


Building Modular APIs with Grape and Rails
http://priyaaank.tumblr.com/post/34018821171/building-modular-apis-with-grape-and-rails

This is the most detailed and interesting article out of all which I’ve listed so far. Priyank Gupta have written a detailed post explaining how he built his API using Grape, Rails and MongoDB.