Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RESTful API with Grape
Search
Charles Lalonde
May 20, 2016
Programming
230
0
Share
RESTful API with Grape
Charles Lalonde
May 20, 2016
Other Decks in Programming
See All in Programming
さぁV100、メモリをお食べ・・・
nilpe
0
130
New "Type" system on PicoRuby
pocke
1
450
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
140
ふつうのFeature Flag実践入門
irof
7
3.5k
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
440
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.8k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
190
AIエージェントの隔離技術の徹底比較
kawayu
0
460
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
710
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
120
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
610
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
270
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.7k
Agile that works and the tools we love
rasmusluckow
331
21k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
190
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Rails Girls Zürich Keynote
gr2m
96
14k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
430
Marketing to machines
jonoalderson
1
5.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Git: the NoSQL Database
bkeepers
PRO
432
67k
How to Talk to Developers About Accessibility
jct
2
220
Unsuck your backbone
ammeep
672
58k
Designing for Timeless Needs
cassininazir
1
250
Transcript
RESTful API with Grape
Hi, I’m Charles Rails Developer @ Unsplash
Unsplash Do whatever you want high-resolution photos
None
None
None
None
None
None
Why Grape?
Why Grape? • Framework to build API • Easily extensible
• Supports Rails, Sinatra and others
Setup Rails in 4 simple steps
• app/ • api/ • v1/ • base.rb Create folder
structure Setup Rails in 4 simple steps
Setup Rails in 4 simple steps Auto load the API
files in your application.rb
Mount the API in routes.rb Setup Rails in 4 simple
steps
Setup Rails in 4 simple steps • Versioning • Format
• Endpoint mounting • Default headers • Logs
{ Grape } Basic
{ Grape } Basic • Call Overview • Headers •
Parameters • Http Methods • Error Handling • Helpers
Overview • Resource • Route params • HTTP methods •
Parameters GET api.montrealrb.com/v1/:resource/:route_param
Headers • Useful for bots • Alerting users of deprecated
endpoints • Allow multiple origins • etc
Parameters • Can manage optional and required params • Multiple
parameter types • Custom validation
HTTP methods • Supports all HTTP methods • Specify endpoint
names
Error handling • Message • Status
Helpers • Create reusable code • Can include custom modules
{ Grape } gem extension
{ Grape } gem extension WineBouncer Oauth2 protection with
Doorkeeper https://github.com/antek-drzewiecki/wine_bouncer grape-rails-cache Server side cache https://github.com/monterail/grape-rails-cache grape-swagger Automatically generate documentation https://github.com/ruby-grape/grape-swagger
{ Grape } gem extension
Demo
Unsplash API Stats API Requests 230 740 265 Last 30
days API Developers 2 479 Approved Applications 184
Connect @dechuck on Twitter, GitHub & Unsplash Thanks