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
87
Swift Concurrencyを利用したUIViewController表示の排他制御の実装
to4iki
0
3.3k
ケースに応じたUICollectionViewのレイアウト実装パターン
to4iki
1
4.8k
ビューインプレッションの計測方法
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
Android 16KBページサイズ対応をはじめからていねいに
mine2424
0
440
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
1
7.3k
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
220
おやつのお供はお決まりですか?@WWDC25 Recap -Japan-\(region).swift
shingangan
0
140
状態遷移図を書こう / Sequence Chart vs State Diagram
orgachem
PRO
2
200
生成AI時代のコンポーネントライブラリの作り方
touyou
1
290
GPUを計算資源として使おう!
primenumber
1
250
RailsGirls IZUMO スポンサーLT
16bitidol
0
200
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
240
型で語るカタ
irof
0
700
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
1.1k
Git Sync を超える!OSS で実現する CDK Pull 型デプロイ / Deploying CDK with PipeCD in Pull-style
tkikuc
4
350
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Designing for Performance
lara
610
69k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Side Projects
sachag
455
42k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
54k
A Tale of Four Properties
chriscoyier
160
23k
Adopting Sorbet at Scale
ufuk
77
9.5k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.7k
4 Signs Your Business is Dying
shpigford
184
22k
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࠷৽͔νΣοΫͱ͔)
͓ΘΓ