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
REST my dongle #kreait-dev-days
Search
Armen Mkrtchyan
June 05, 2015
Programming
1
120
REST my dongle #kreait-dev-days
REST best practices, HAL, HATEOAS
Armen Mkrtchyan
June 05, 2015
Tweet
Share
More Decks by Armen Mkrtchyan
See All by Armen Mkrtchyan
Api Protection
iamtankist
2
450
Life on the edge between AngularJS and Symfony2
iamtankist
9
3.7k
Other Decks in Programming
See All in Programming
最新のDirectX12で使えるレイトレ周りの機能追加について
projectasura
0
240
ゼロダウンタイムでミドルウェアの バージョンアップを実現した手法と課題
wind111
0
110
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
380
Register is more than clipboard
satorunooshie
1
470
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Data Structures: Linked Lists and Queues for Reactivity
konkarin
1
290
自動テストを活かすためのテスト分析・テスト設計の進め方/JaSST25 Shikoku
goyoki
3
660
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
280
Amazon Bedrock Knowledge Bases Hands-on
konny0311
0
150
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
4
1.6k
問題の見方を変える「システム思考」超入門
panda_program
0
200
ビルドプロセスをデバッグしよう!
yt8492
0
310
開発生産性が組織文化になるまでの軌跡
tonegawa07
0
160
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.2k
Rails Girls Zürich Keynote
gr2m
95
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
930
A designer walks into a library…
pauljervisheath
210
24k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
BBQ
matthewcrist
89
9.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
670
Transcript
Logitech R400
Slide 1
Slide 2
GET /slides
[ { "id": 1, "content": "Slide 1" }, { "id":
2, "content": "Slide 2" }, ]
GET /slide/1
{ "id": 1, "content": "Slide 1", "background": "white", "text": "#031337"
}
Verb Method GET /slides Get list of slides C POST
/slides Create new slide R GET /slides/:id Get specific slide U PUT /slides/:id Update slide D DELETE /slides/:id Delete slide
Next Previous
None
1. GET /slides 2. Remember IDs 3. Figure out index
4. index++ 5. GET /slides/2
GET /slides/1/next GET /nextSlide/1
REST Maturity Model
HATEOAS (Hypertext As The Engine Of Application State) Level 3:
Hypermedia HAL (Hypertext Application Language)
{ "id": 5, "content": "Slide 1", "background": "white", "text": "#031337"
"_links": { "self": { "href": "/slides/5" }, "prev": { "href": "/slides/4" }, "next": { "href": "/slides/6" }, "first": { "href": "/slides/1" }, "last": { "href": "/slides/12" } } }
HAL + JSON http://stateless.co/hal_specification.html
R(B)EST practices
1. Do not use verbs /getAllSlides /createNewSlide /deleteAllBlackSlides GET /slides
POST /slides DELETE /slides?filter=black
2. GET method should NEVER alter the state GET /slide/1?action=disable
POST /slides/1/disable or PUT /slides/1/disable
3. Use plural nouns /slide /slides
4. Use sub-resources for relations GET /animationsForSlide/1 DELETE /animationsFromSlide/1/2 GET
/slides/1/animations/ DELETE /slides/1/animations/3
5. Use HTTP headers for serialization formats Content-type: application/vnd+com.kreait.slide+json
6. Use HAL { "id": 1, "content": "Slide 1", "background":
"white", "text": "#031337" "_links": { "self": { "href": "/slides/1" }, "next": { "href": "/slides/2" } } }
7. Filtering, Sorting, field selection and paging Filter GET /slides?background=white
Sort GET /slides?sort=-title,+length Limit Fields GET /slides?fields=id,title Pagination GET /slides?offset=10&limit=5
8. Version your API In URL: /api/v1/slides
9. Handle Errors with HTTP status codes http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html and https://github.com/joho/7XX-rfc
Errors in vnd.error format (https://github.com/blongden/vnd.error) or at least something consistent
10. Allow overriding HTTP method X-HTTP-Method-Override: PUT
Dongle included Thanks!