# ruby-grape/grape

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/ruby-grape-grape).**

9,988 stars · 1,230 forks · Ruby · MIT

## Links

- GitHub: https://github.com/ruby-grape/grape
- Homepage: http://www.ruby-grape.org
- awesome-repositories: https://awesome-repositories.com/repository/ruby-grape-grape.md

## Description

Grape is a RESTful web service framework for Ruby designed for building structured APIs. It provides a declarative syntax for routing and parameter validation, allowing developers to map HTTP verbs to logic through a domain specific language.

The framework is distinguished by its built-in support for service versioning, which can be managed via URL paths, custom headers, or request parameters. It also features a modular architecture that allows large services to be constructed by nesting smaller API definitions.

The project covers comprehensive API lifecycle capabilities, including schema-driven input validation, type coercion, and content negotiation for various media types. It utilizes a middleware-based request pipeline for injecting custom logic and offers tools for entity-based response formatting and automated specification generation.

The framework includes built-in mechanisms for request authentication and standardized error response mapping.

## Tags

### Web Development

- [API Versioning](https://awesome-repositories.com/f/web-development/api-versioning.md) — Supports multiple concurrent API versions managed via URL paths, request parameters, or custom headers. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [RESTful API Development](https://awesome-repositories.com/f/web-development/restful-api-development.md) — Provides a declarative framework for building scalable web services using standard HTTP methods and architectural patterns.
- [API Parameter Validation](https://awesome-repositories.com/f/web-development/api-parameter-validation.md) — Implements advanced rules for input data, including mutual exclusivity and dependency between different parameters. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Request Body Parsers](https://awesome-repositories.com/f/web-development/backend-development/middleware-pipelines/request-body-parsers.md) — Processes incoming data based on the content-type using JSON, XML, or custom parsers. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Query Parameter Validations](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/query-parameter-validations.md) — Implements strict constraints on query and request parameters using regular expressions and length limits. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Parameter Coercion and Validation](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/query-parameter-validations/parameter-coercion-and-validation.md) — Features a declarative system for coercing, validating, and filtering incoming request parameters using specific types and constraints.
- [Middleware Pipelines](https://awesome-repositories.com/f/web-development/middleware-pipelines.md) — Inserts custom logic into the processing flow by implementing a base middleware class. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Modular API Composition](https://awesome-repositories.com/f/web-development/modular-api-composition.md) — Provides a modular architecture allowing large services to be constructed by nesting smaller API definitions. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Request Middleware](https://awesome-repositories.com/f/web-development/request-middleware.md) — Provides an interceptor stack for injecting custom logic into the request-response execution pipeline.
- [Request Parameter Parsers](https://awesome-repositories.com/f/web-development/request-parameter-parsers.md) — Provides a declarative system for defining required fields, types, and default values for incoming request data. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Request Validation](https://awesome-repositories.com/f/web-development/request-validation.md) — Ensures incoming data meets specific type, presence, and format requirements before reaching business logic.
- [Response Formatters](https://awesome-repositories.com/f/web-development/response-formatters.md) — Converts output data into specified media types like JSON or XML using built-in or custom formatters. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Response Formatting](https://awesome-repositories.com/f/web-development/response-formatting.md) — Provides built-in mechanisms to convert output data into specified media types like JSON or XML using customizable formatters.
- [REST API Frameworks](https://awesome-repositories.com/f/web-development/rest-api-frameworks.md) — Offers a declarative Ruby framework for building structured HTTP endpoints that handle parameter validation and data serialization.
- [REST Frameworks](https://awesome-repositories.com/f/web-development/rest-frameworks.md) — Provides a comprehensive framework for building RESTful web services with integrated content negotiation and formatting.
- [HTTP Routing](https://awesome-repositories.com/f/web-development/routing-systems/http-routing.md) — Directs incoming HTTP traffic to specific handlers based on the request method and path. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [API Endpoint Metadata](https://awesome-repositories.com/f/web-development/api-endpoint-metadata.md) — Attaches metadata and security requirements to routes to create automatic documentation for users. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Specification Generators](https://awesome-repositories.com/f/web-development/api-schema-generation/specification-generators.md) — Uses endpoint metadata to automatically produce standardized, machine-readable API specifications. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [API Specification Generation](https://awesome-repositories.com/f/web-development/api-specification-generation.md) — Uses endpoint metadata to automatically produce standardized, machine-readable API specifications for external consumers.
- [Middleware Pipelines](https://awesome-repositories.com/f/web-development/backend-development/middleware-pipelines.md) — Utilizes a middleware-based request pipeline to inject custom logic and filters into the HTTP execution flow.
- [Response Header Modifiers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/response-metadata-accessors/response-header-modifiers.md) — Provides utilities to set and merge HTTP response headers, including during error transitions. ([source](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md))
- [Content Negotiation](https://awesome-repositories.com/f/web-development/content-negotiation.md) — Determines the appropriate response format by matching request headers against supported media types.
- [Custom Content Negotiators](https://awesome-repositories.com/f/web-development/custom-content-negotiators.md) — Allows the definition of supported media types and configuration of custom parsers for non-standard input formats. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Entity-Based Response Formatters](https://awesome-repositories.com/f/web-development/entity-based-response-formatters.md) — Implements a transformation layer to map internal Ruby objects to specific public attributes for consistent output.
- [Entity-Based Response Formatting](https://awesome-repositories.com/f/web-development/entity-based-response-formatting.md) — Transforms raw objects into structured responses using representative entities to expose specific attributes. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Error Response Mappers](https://awesome-repositories.com/f/web-development/error-response-mappers.md) — Customizes the structure and content of error responses using a standardized response object. ([source](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md))
- [HTTP Content Negotiation](https://awesome-repositories.com/f/web-development/http-content-negotiation.md) — Determines the response format by interpreting the Accept header according to standard web specifications. ([source](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md))
- [Media Type Restrictions](https://awesome-repositories.com/f/web-development/media-type-restrictions.md) — Manages the media types a service accepts or produces to ensure compatible communication between clients. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Request Lifecycle Hooks](https://awesome-repositories.com/f/web-development/request-lifecycle-hooks.md) — Provides hooks to execute custom logic before or after endpoint processing to handle cross-cutting concerns. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Request Parameter Filtering](https://awesome-repositories.com/f/web-development/request-parameter-filtering.md) — Extracts only the explicitly defined parameters from a request while removing all undeclared data. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))

### Programming Languages & Runtimes

- [Routing DSLs](https://awesome-repositories.com/f/programming-languages-runtimes/domain-specific-languages/routing-dsls.md) — Provides a declarative domain-specific language for mapping HTTP verbs and paths to logic handlers.

### Software Engineering & Architecture

- [Version-Aware Route Dispatching](https://awesome-repositories.com/f/software-engineering-architecture/configuration-versioning/version-aware-route-dispatching.md) — Selects endpoints based on versions extracted from the URL path, headers, or request parameters.
- [Data Validation Schemas](https://awesome-repositories.com/f/software-engineering-architecture/data-validation-schemas.md) — Enforces data constraints and required fields using a declarative parameter specification.
- [Endpoint Routing](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/api-design-management/api-patterns/controller-based-routing/endpoint-routing.md) — Maps incoming URL paths to specific logic handlers and endpoints. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Request Middleware](https://awesome-repositories.com/f/software-engineering-architecture/request-middleware.md) — Adds custom logic at specific points in the execution stack to modify the request-response flow. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Type Coercion Utilities](https://awesome-repositories.com/f/software-engineering-architecture/type-coercion-utilities.md) — Transforms input strings into specific data types or custom classes using defined parsing methods. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Error Mapping Strategies](https://awesome-repositories.com/f/software-engineering-architecture/error-mapping-strategies.md) — Catches errors raised during execution and maps them to specific response handlers or generic errors. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))
- [Nested API Definitions](https://awesome-repositories.com/f/software-engineering-architecture/modular-program-composition/nested-api-definitions.md) — Allows large services to be constructed by nesting smaller, modular API definitions.

### Security & Cryptography

- [HTTP Request Filtering](https://awesome-repositories.com/f/security-cryptography/http-request-filtering.md) — Includes mechanisms to intercept and filter incoming HTTP requests for authentication and logging purposes. ([source](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md))
- [Request Authentication Middleware](https://awesome-repositories.com/f/security-cryptography/request-authentication-middleware.md) — Protects API endpoints using built-in HTTP Basic authentication and customizable authentication middleware strategies. ([source](https://github.com/ruby-grape/grape/blob/master/README.md))

### Part of an Awesome List

- [API Development](https://awesome-repositories.com/f/awesome-lists/devtools/api-development.md) — Microframework for creating RESTful APIs.
- [API Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/api-frameworks.md) — A micro-framework for creating REST-like APIs in Ruby.
- [Language Toolkits](https://awesome-repositories.com/f/awesome-lists/devtools/language-toolkits.md) — Opinionated framework for creating REST-like APIs.
