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
33
api-design-practice.pdf
to4iki
September 07, 2014
Tweet
Share
More Decks by to4iki
See All by to4iki
Claude Code の活用事例
to4iki
0
81
Swift Concurrencyを利用したUIViewController表示の排他制御の実装
to4iki
0
3.3k
ケースに応じたUICollectionViewのレイアウト実装パターン
to4iki
1
4.7k
ビューインプレッションの計測方法
to4iki
1
1.1k
秘伝の `gitconfig`
to4iki
1
450
Abema iOS Architecture
to4iki
12
3.4k
timetable-bot
to4iki
0
14k
BLoC Pattern Introduction with Swift
to4iki
2
1.3k
nel
to4iki
0
160
Other Decks in Programming
See All in Programming
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
800
Discover Metal 4
rei315
2
120
Code as Context 〜 1にコードで 2にリンタ 34がなくて 5にルール? 〜
yodakeisuke
0
120
関数型まつりレポート for JuliaTokai #22
antimon2
0
160
CursorはMCPを使った方が良いぞ
taigakono
1
240
Team operations that are not burdened by SRE
kazatohiei
1
310
Is Xcode slowly dying out in 2025?
uetyo
1
260
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
330
RailsGirls IZUMO スポンサーLT
16bitidol
0
170
新メンバーも今日から大活躍!SREが支えるスケールし続ける組織のオンボーディング
honmarkhunt
3
6k
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
130
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
1
140
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
We Have a Design System, Now What?
morganepeng
53
7.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
Six Lessons from altMBA
skipperchong
28
3.9k
How to train your dragon (web standard)
notwaldorf
94
6.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
How to Ace a Technical Interview
jacobian
277
23k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Designing Experiences People Love
moore
142
24k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
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࠷৽͔νΣοΫͱ͔)
͓ΘΓ