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
ゆくKotlin くるRust
exoego
1
200
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
170
Grafana:建立系統全知視角的捷徑
blueswen
0
290
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
360
CSC307 Lecture 01
javiergs
PRO
0
670
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.5k
GISエンジニアから見たLINKSデータ
nokonoko1203
0
190
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.5k
AgentCoreとHuman in the Loop
har1101
5
170
はじめてのカスタムエージェント【GitHub Copilot Agent Mode編】
satoshi256kbyte
0
180
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
210
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
360
Featured
See All Featured
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
99
Statistics for Hackers
jakevdp
799
230k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Discover your Explorer Soul
emna__ayadi
2
1k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
67
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
150
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
150
The agentic SEO stack - context over prompts
schlessera
0
590
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
エンジニアに許された特別な時間の終わり
watany
106
230k
Done Done
chrislema
186
16k
Claude Code のすすめ
schroneko
67
210k
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!