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
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
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
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
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
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
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.