
Grape
A Ruby framework for building REST-style web APIs with a simple DSL.
- Stars
- 10k
- Forks
- 1.2k
- Licence
- MIT
- Language
- Ruby
- Last update
- 5 days ago
- Type
- Library
What it is
Grape is a framework for building REST-like APIs in Ruby. It runs on Rack and can also sit alongside existing web frameworks such as Rails and Sinatra. It provides a small DSL for defining endpoints and includes built-in support for things like multiple formats, versioning, and content negotiation.
- Define endpoints for listing, creating, updating and deleting resources, as the Twitter-style example in the README shows
- Mount a Grape API inside a Rails app under app/api
- Run a Grape API alongside a Sinatra app using Rack::Cascade
- Share endpoint code across versions or components by mounting APIs inside each other
Great for
- Ruby developers who need to build a REST-style JSON API
- Teams adding an API alongside an existing Rails or Sinatra app
- Projects that want versioning and mountable API components
Not ideal for
- People who need a complete web app with views and front-end pages, since Grape focuses on APIs
- Non-Ruby teams, because it is a Ruby gem
- Beginners with no Ruby experience, since the README assumes familiarity with Rack and Ruby classes
How to get it
- 1
Install with a package manager
You'll need: Ruby 3.3.1 or newer
Add the gem to your project
bundle add grape - 2
Run it
- Install Ruby 3.3.1 or newer
- Run bundle add grape in your project
- Create a class that subclasses Grape::API and define a route such as get :hello
- Run it as a Rack app with a config.ru file and rackup
- 3
Get the most out of it
- Call compile! before serving requests to preload routes
- Use mount with a path or configuration hash to reuse endpoints in multiple places
- Use rescue_from and error! to handle errors consistently
- Add desc and params blocks to document and validate endpoints
Downloads
Strengths
- Simple DSL for defining REST-like routes
- Built-in support for versioning, formats, and content negotiation
- Works with Rack and integrates with Rails and Sinatra
Trade-offs
- Requires Ruby 3.3.1 or newer, which may rule out older projects
- Mounting alongside other frameworks has ordering rules that can cause surprising 404 behavior if misconfigured
- The README is truncated, so some details beyond the basics are not covered here
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| grape (this) | 10k | Library | intermediate | 5 days ago | Ruby developers who need to build a REST-style JSON API |
| sinatra | 12.5k | Library | beginner | 4 months ago | Ruby developers who want a small, readable web app or API |
| chi | 23k | Library | intermediate | 19 days ago | Go developers building REST API services |
| fastapi | 105k | Library | beginner | 4 days ago | Python developers building JSON APIs or back-end services |
| hoppscotch | 80.7k | App | beginner | 6 days ago | Developers who want to test REST, GraphQL, WebSocket, or other APIs without a heavy desktop client |
| imgui | 76.9k | Library | intermediate | 6 days ago | Game developers who want an in-engine debug or tools panel |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.