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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Charles Lalonde
May 20, 2016
Programming
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RESTful API with Grape
Charles Lalonde
May 20, 2016
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
0
320
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
2k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
180
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
6
4k
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2k
Lessons from Spec-Driven Development
simas
PRO
0
170
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
560
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
350
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
2
1.3k
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
HDC tutorial
michielstock
2
700
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.7k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
610
Building AI with AI
inesmontani
PRO
1
1.1k
ラッコキーワード サービス紹介資料
rakko
1
3.6M
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
320
Visualization
eitanlees
152
17k
エンジニアに許された特別な時間の終わり
watany
107
250k
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