Grape

在 Ruby 中创建类似 REST api 的、偏向于自己使用的框架。「An opinionated framework for creating REST-like APIs in Ruby.」

Github stars Tracking Chart

grape logo

Gem Version
Build Status
Code Climate
Coverage Status
Inline docs
Join the chat at https://gitter.im/ruby-grape/grape

Table of Contents

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.

Stable Release

You're reading the documentation for the next release of Grape, which should be 1.3.1.
Please read UPGRADING when upgrading from a previous version.
The current stable release is 1.3.0.

Project Resources

Installation

Ruby 2.4 or newer is required.

Grape is available as a gem, to install it just install the gem:

gem install grape

If you're using Bundler, add the gem to Gemfile.

gem 'grape'

Run bundle install.

Basic Usage

Grape APIs are Rack applications that are created by subclassing Grape::API.
Below is a simple example showing some of the more common features of Grape in
the context of recreating parts of the Twitter API.

module Twitter
  class API < Grape::API
    version 'v1', using: :header, vendor: 'twitter'
    format :json
    prefix :api

    helpers do
      def current_user
        @current_user

Main metrics

Overview
Name With Ownerruby-grape/grape
Primary LanguageRuby
Program languageRuby (Language Count: 3)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2010-08-02 14:25:08
Pushed At2025-05-09 22:42:13
Last Commit At2025-05-09 18:42:12
Release Count74
Last Release Namev2.3.0 (Posted on 2025-02-08 14:32:52)
First Release Namev0.0.0.alpha.1 (Posted on )
用户参与
Stargazers Count9.9k
Watchers Count207
Fork Count1.2k
Commits Count2.8k
Has Issues Enabled
Issues Count1183
Issue Open Count222
Pull Requests Count1032
Pull Requests Open Count32
Pull Requests Close Count311
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private