Grape: A REST-like API Framework for Ruby

grape logo

Gem Version test Coverage Status

What is Grape?

Grape is a REST-like API framework for Ruby. It's designed to run on Rack or complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily develop RESTful APIs. It has built-in support for common conventions, including multiple formats, subdomain/prefix restriction, content negotiation, versioning and much more.

Key Features

  • Simple DSL: A straightforward and intuitive DSL for building your API.
  • Versioning: Built-in support for API versioning through paths, headers, or parameters.
  • Content Negotiation: Automatic content negotiation for various formats like JSON and XML.
  • Parameter Validation & Coercion: Powerful parameter validation, coercion, and support for custom types.
  • Middleware Support: A robust middleware architecture for authentication, logging, and more.
  • Entity Support: Integration with grape-entity for fine-grained control over response representations.
  • Framework Agnostic: Runs on Rack and can be easily mounted within Rails, Sinatra, or any other Rack-based framework.

Getting Started

Ready to build your first API with Grape? Follow these steps:

  1. Installation: Get Grape installed and set up in your project.
  2. Quick Start: Build a simple "Hello World" API in just a few lines of code.

Grape for Enterprise

Grape is available as part of the Tidelift Subscription. The maintainers of Grape are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.