What is Grape?
Tags: ruby, codenewbie, womenintech
Published: 2019-05-21 22:11:33

---
title: What is Grape?
published: true
description: A quick introduction of Grape, a Ruby micro-framework.
tags: ruby, code newbie, women in tech
---

In my [previous blog post/tutorial](https://dev.to/torianne02/sequel-an-alternative-to-activerecord-5d6l), I discussed a coding challenge I was given to build a Ruby RESTful API without using Rails. This last post, I walked through the Ruby gem Sequel. Today, I want to discuss another Ruby gem I had never heard of before this coding challenge: Grape. 

*Note: While I am discussing this gem, this will not be a tutorial, unlike my previous post on Sequel.*

### First Things First: What is Grape?

Grape is a “REST-like API framework for Ruby” that is designed to run on Rack or run alongside other Ruby frameworks, such as Rails and Sinatra.  When being used alongside other Ruby frameworks, Grape makes it easier to develop RESTful API’s by supplying an easy to use DSL. 

### Wait! What is a DSL? 

If you are like me and still consider yourself a code newbie, you may be thinking what is DSL and what does it have to do with Ruby? When I first read DSL, I immediately thought of internet speed and had no idea what it had to do with anything. Turns out, after lots of googling, that DSL stands for Domain-Specific Language. 

Now you must be thinking, what is this gibberish? To keep it simple, a DSL is a programming language that focuses on a specific problem/task. They make it easier for the developer because it removes “extraneous code for a particular task” and allows the developer to “focus specifically on the task at hand.” In layman’s terms, this means that the DSL’s do a lot of the busy/repetitive code in the background so that the developer doesn’t have to. 

### How Does Grape Act as a DSL? 

Well, according to Grape official documentation, it makes it much easier to build a RESTful API because “it has built-in support for common conventions, including multiple formats, subdomain/prefix restriction, content negotiations, versioning and much more.” 

Grape also works alongside other Ruby gems that help make a RESTful API even easier. Grape supports CORS via the `rack-cors` gem. You could even use Active Model Serializers by installing the `grape-active_model_serializers` gem.  

One thing I loved about Grape is that I could still use familiar gems alongside it, which made it even easier for me to follow. There are numerous gems that compliment it, as well as others that are built and maintained specifically to work with Grape, just like the `grape-active_model_serializers` gem. 

### Grape Community Projects

Within the official documentation of Grape, there is a community projects page that lists all projects currently being built/maintained by Grape that work alongside the gem to help provide an even smoother experience of building a RESTful API. 

This page can be found [here](http://www.ruby-grape.org/projects/), but here is a list of a few helpful ones I think are worth noting:

[grape-entity](https://github.com/ruby-grape/grape-entity)
[grape-activerecord](https://github.com/jhollinger/grape-activerecord)
[grape-active_model_serializers](https://github.com/ruby-grape/grape-active_model_serializers)
[garner](https://github.com/artsy/garner)
[grape-cors](https://github.com/adamluzsi/grape-cors)
[grape-batch](https://github.com/c4mprod/grape-batch)
[grape-route-helpers](https://github.com/reprah/grape-route-helpers)
[grape_logging](https://github.com/aserafin/grape_logging)
[grape-swagger](https://github.com/ruby-grape/grape-swagger)
[grape-swagger-entity](https://github.com/ruby-grape/grape-swagger-entity)
[grape-scaffold](https://github.com/icicletech/grape-scaffold)

### Final Thoughts

I really enjoyed using Grape. Its simplicity made it really easy to understand and use. I believe Grape is an incredibly useful tool to help build clean and efficient RESTful API’s in Ruby. I really enjoyed how clean my code looked and how self explanatory it all was. I am someone who comments my code quite a bit, so the fact that I didn’t feel the need to do so was a win in and of itself. 

I also really like that there are other Grape related gems that add-on functionalities and are built and maintained by the Grape team. They allow people to contribute as well, which is a great idea for anyone who is looking for an open source project.

I hope this quick rundown of Grape intrigues you to use it within a future project. I can't wait to get more experience with it. 

Happy coding! 

#### Sources
[Ruby Grape](https://github.com/ruby-grape/grape#active-model-serializers)
[Ruby Grape: History and Team](http://www.ruby-grape.org/team/)
[Making a Rails API with Grape](https://www.thegreatcodeadventure.com/making-a-rails-api-with-grap/)