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
api-design-practice.pdf
Search
to4iki
September 07, 2014
Programming
0
26
api-design-practice.pdf
to4iki
September 07, 2014
Tweet
Share
More Decks by to4iki
See All by to4iki
suspend-view-controller-sample
to4iki
0
2.6k
ケースに応じたUICollectionViewのレイアウト実装パターン
to4iki
1
4.2k
ビューインプレッションの計測方法
to4iki
0
910
秘伝の `gitconfig`
to4iki
1
400
Abema iOS Architecture
to4iki
12
3.2k
timetable-bot
to4iki
0
14k
BLoC Pattern Introduction with Swift
to4iki
2
1.2k
nel
to4iki
0
120
[iOS] ビデオチームのスモールスクラム
to4iki
0
48
Other Decks in Programming
See All in Programming
Sheets API使ってみた
toshi0383
2
150
SIMD Parallel Programming with the Vector API
josepaumard
0
220
Elm 0.19.0 Changes
bkuhlmann
0
490
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
990
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
960
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
160
Goのエラースタックトレースの歴史と今後
sonatard
9
1.7k
try! Swift Tokyo 初参加報告LT
hinakko2
0
230
What We Can Learn From OSS
inouehi
0
430
Micro Frontends for Java Microservices - Utah JUG 2024
mraible
PRO
1
100
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
270
Goのmultiple errorsについて (2024年4月版)
syumai
4
1.1k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
6
1.3k
Teambox: Starting and Learning
jrom
128
8.4k
What's in a price? How to price your products and services
michaelherold
238
11k
Build The Right Thing And Hit Your Dates
maggiecrowley
25
2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
123
39k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
13
8.3k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
Stop Working from a Prison Cell
hatefulcrawdad
267
19k
Fontdeck: Realign not Redesign
paulrobertlloyd
76
4.9k
How GitHub (no longer) Works
holman
305
140k
BBQ
matthewcrist
80
8.8k
Transcript
API ઃܭͰҙ͍ͯ͠Δࣄ toshiki takezawa @to4iki
None
ࠓ͔Βͷ༰ ͋͘·Ͱ։ൃऀࢹͰ͢ APIΛ࡞ΔࢹͰ
લఏ REST ~.pl ~.do ~servletͱ͔ ಛఆݴޠʹґଘ͍ͯ͠Δ͔ΒγεςϜมߋ͠ ʹ͍͘ɻ FW(struts → rails)ͱ͔ม͑ͨΒURLมΘΔ
ΑͶ ! ɾwebΛࢧ͑Δٕज़ಡ͏
1. ಈࢺͰͳ໊͘ࢺ ɾϦιʔεΛ໊ࢺͰද͢ collectionͰ υϝΠϯʹΑͬͯಈࢺ͋Γ /convert?from=EUR&to=CNY&amount=100` ɾHTTP ϝιουΛϦιʔεͷૢ࡞ͱ͢Δ get, post,
put, delete ɾ֊ͳΔ͚ͩઙ͘อͭɺγϯϓϧʹ /users/5678/dogs /resource/identifier/resource ͕҆ ɾURLʹϝιουΛؚΊͳ͍ /users/show/123ͱ͔ → /users/123 ɾෳࡶ͞ΫΤϦύϥϝʔλʹԡ͠ࠐΉ /users?q=hoge&offset=50&limit=30
2. ΤϥʔϋϯυϦϯά ɾεςʔλείʔυΛదʹ༻͢Δ 200: success 400൪: client error 404: not
found 409 conflict 500: server error
3. όʔδϣχϯά ɾAPI ͷϨεϙϯεΛϋϯυϧͯ͠ϩδοΫ͕มΘΔ ߹, URL ʹ͍ΕΔ ͔ͯɺೖΕͳ͍ͱޓੑͬͨมߋ͘Θ͑ͨͱ͖ࢮ ͵ /api/1.0/dogs
/api/1.1/dogs ! AcceptsϔομʔͰόʔδϣχϯάͯ͠
4. ϦιʔεͷUUIDΛఏڙ͢Δ “uuid":"39D3FA7E-‐29F5-‐4406-‐9B54-‐AE70FA3CBF87" ! sequenceͰ͍͍ͱࢥ͏͚Ͳ ! mysqlͳΒ SELECT UUID()
AS u ! postgreσϑΥϧτରԠͯ͠ͳ͍͔Β uuid-ossp͍ΕͯͶ
5. ϦιʔεͷtimestampΛఏڙ͢Δ { "createTime":1406391453253, "modifyTime":1406421657000
}
6. ֎෦Ωʔͷࢀষωετ͢Δ "name":"fute", "ownerId": “13524-‐...", !
Ͱͳ͘ ! "name":"fute", "owner": { "id": "13524-‐...", } ϨεϙϯεͷߏΛมߋͨ͠ΓɺτοϓϨϕϧͷϑΟʔ ϧυΛՃ͢Δࣄͳ͘ɺؔ࿈ใΛؚΊΔࣄ͕Ͱ͖Δ
7. Ϧιʔεࢀরͷalias༻ҙ͠ͱ͘ ɾid /users/:id ɾname /users/:name ɾmail /users/:mail
ଞʹ ɾAPIΞΫηεSSLඞਢʹ͍͔ͨ͠ ɾdocumentॆ࣮ͤ͞Α͏ ɾEtagͰΩϟογϡαϙʔτͱ͔ (ΫϥΠΞϯτͷif-none-matchϔομͰ cache࠷৽͔νΣοΫͱ͔)
͓ΘΓ