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
Web APIについての雑談
Search
Tomohiro Nishimura
December 23, 2015
Technology
0
410
Web APIについての雑談
よく悩むところを列挙しました
Tomohiro Nishimura
December 23, 2015
Tweet
Share
More Decks by Tomohiro Nishimura
See All by Tomohiro Nishimura
レガシーシステム洗い出し大作戦
sixeight
0
1.6k
我々のRealmはどこからやってくるのか
sixeight
1
400
まだ見ぬAPIに思いを馳せて
sixeight
0
130
復習OptionSet
sixeight
0
270
今年読んだまんが
sixeight
0
230
べんりな検索ワード
sixeight
0
240
Readable Width in action
sixeight
0
170
UIPreviewInteraction: Overview
sixeight
1
620
Accessing the Music Library
sixeight
1
2.7k
Other Decks in Technology
See All in Technology
Understanding Go GC #coefl_go_jp
bengo4com
0
1.1k
どこで動かすか、誰が動かすか 〜 kintoneのインフラ基盤刷新と運用体制のシフト 〜
ueokande
0
190
Yahoo!ニュースにおけるソフトウェア開発
lycorptech_jp
PRO
0
390
microCMS 最新リリース情報(microCMS Meetup 2025)
microcms
0
120
退屈なことはDevinにやらせよう〜〜Devin APIを使ったVisual Regression Testの自動追加〜
kawamataryo
3
740
実践アプリケーション設計 ③ドメイン駆動設計
recruitengineers
PRO
7
700
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
susisu
7
1.9k
Amazon Bedrock AgentCore でプロモーション用動画生成エージェントを開発する
nasuvitz
6
450
実践アプリケーション設計 ①データモデルとドメインモデル
recruitengineers
PRO
4
450
Yahoo!広告ビジネス基盤におけるバックエンド開発
lycorptech_jp
PRO
1
280
新規案件の立ち上げ専門チームから見たAI駆動開発の始め方
shuyakinjo
0
140
.NET開発者のためのAzureの概要
tomokusaba
0
230
Featured
See All Featured
For a Future-Friendly Web
brad_frost
179
9.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
How GitHub (no longer) Works
holman
315
140k
Building an army of robots
kneath
306
46k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
780
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.5k
Building Applications with DynamoDB
mza
96
6.6k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Docker and Python
trallard
45
3.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Building Adaptive Systems
keathley
43
2.7k
Transcript
Web API ʹ͍ͭͯͷࡶஊ ؔϞό #9
ג ͯͳ 8FCΞϓϦέʔγϣϯΤϯδχΞ εϚʔτϑΥϯΞϓϦΤϯδχΞ ͲΕத్ͰযΔ ޚࡏॴַΑ͔ͬͨ id:Sixeight (@tomohi_ro)
Web API ΣϒΤʔϐʔΞΠ
ؔϞό#9 Web API ͱͳΜͧ )551ϓϩτίϧΛར༻ͯ͠ωοτϫʔ Ϋӽ͠ʹݺͼग़͢"1* 8FC"1*5IF(PPE1BSUT
εϚʔτϑΥϯΞϓϦ ͱ Web API
͑ͳ͍
ؔϞό#9 LSUDs ͱSSKDs ▸ LSUDs (large set of unknown developers)
▸ ͘Ұൠతʹެ։͞Ε͍ͯΔ ▸ Twitter/Facebook/Instagram/ Google/etc ▸ SSKDs (small set of known developers) ▸ ݶΒΕͨൣғʹެ։͞Ε͍ͯΔ ▸ ࣗࣾΞϓϦͳͲ
44,%T গͷ͍ͬͯΔ։ൃऀ͚
ؔϞό#9 SSKDs (small set of known developers) ▸ ఆ͞Ε͍ͨํ͔͠͞Εͳ͍ ▸
ΞϓϦʹ࠷దԽͨ͠ܗͰఏڙͰ͖Δ ▸ ։ൃऀಉ࢜ͰձͰ͖Δ ▸ ີ݁߹͕ͪ͠ ▸ ଥڠ͕ͪ͠
ίʔϧ 1εΫϦʔϯɺ
ؔϞό#9 1εΫϦʔϯɺ1ίʔϧ ▸ 1ը໘Λදࣔ͢ΔͷʹɺWeb APIͷݺͼग़͠Ұճʹ͓͍͑ͨ͞ ▸ جຊతʹෳͷϦιʔε͕ඞཁ ▸ αʔόʔଆͷ࣮ෳࡶʹͳΔ ▸
ͲΜͲΜRESTͷߟ͑ํ͔ΒͦΕΔ ▸ ҙਂ͘ઃܭ͢ΕՄೳ ▸ ը໘Λத৺ʹߟ͑͗͢Δͱมߋʹऑ͘ͳΔ
ΤϯυϙΠϯτ APIͷإ
ؔϞό#9 ΤϯυϙΠϯτ ▸ SSKDsͩͱΤϯυϙΠϯτͳΜͰ͍͍ͱ͍͏ ▸ ϝϯςφϯεੑ ▸ ݟͨѱ͍ͱΔؾʹӨڹ͢Δ ▸ ෳܥͳͷ͔୯ܗͳͷ͔
▸ HATEOASΈ͍ͨͳͷਅ໘ʹߟ͑ͯྑͦ͞͏
3&45 Ԟ͞Μʹઆ໌͠ΖͱݴΘΕ͍ͯ͠ see also: http://www.geocities.jp/yamamotoyohei/rest/rest-to-my-wife.htm
ؔϞό#9 REST ▸ ͜͜ͰϑΟʔϧσΟϯάͬΆ͍ ▸ 1εΫϦʔϯɺ1ίʔϧͱ૬ੑѱ͍ؾ͕͢Δ ▸ ϩάΞτ DELETE ͳͷ͔Ͳ͏͔
▸ λΠτϧͷߋ৽ PATCHʁʁʁʁʁʁ ▸ ૢ࡞͕ႈͳΒ PUT/DELETEɺͦ͏͡Όͳ͚ΕPOST
Ϩεϙϯε ҙ֎ͱ໎͏
ؔϞό#9 Ϩεϙϯε ▸ ϦιʔεΛߋ৽ͨ͠ͱ͖ͷϨεϙϯεɺߋ৽લʁͦΕͱߋ৽ޙʁ ▸ ϦιʔεΛফͨ͠ͱ͖204? ▸ 200͚ͩΕͲϨεϙϯεཁΒͳ͍ͱ͖ʁ ▸ {“success”:
true} vs {} vs ۭจࣈྻ (←͜Εͳ͍) ▸ ྻΛฦ͢ͱ͖ʹΦϒδΣΫτʹ͢Δ͔Ͳ͏͔ ▸ ͜ΕηΩϡϦςΟͷ͕͋ΔͷͰΦϒδΣΫτͰ ▸ ඞཁͳཁૉ͚ͩʁ֦ுੑΛߟ͑ͯଟΊʹΒ͓ͬͯ͘ʁ ▸ {“user”: { id: 1, name: “hoge”}} vs {“user_id”: 1, “user_name”: “hoge”} ▸ ͷϑΥʔϚοτͲ͏͢Δͷ͔ ▸ ϖʔδϯάͲ͏͢Δͷ͔ ▸ JSONͳͷ͔ଞͷϑΥʔϚοτͳͷ͔
ΤϥʔϨεϙϯε ࣮ॏཁ
ؔϞό#9 ΤϥʔϨεϙϯε ▸ ϑΥʔϚοτݻఆ͍ͨ͠ ▸ ϝοηʔδΛ;͘ΊΔ vs ΞϓϦͰੜ ▸ ଟݴޠԽͲ͏͢Δ͔ɺߋ৽͢͠͞Ͳ͏͔
▸ ΞϓϦଆͰΤϥʔʹର͢ΔέΞ͕ͻͭΑ͏͕Ͳ͏͔ ▸ Τϥʔίʔυඞཁͳͷ͔ ▸ Ͳ͜·Ͱใ͕͍Δͷ͔
ೝূ ࣗͰ͋Δ͜ͱͷূ໌
ؔϞό#9 ೝূ ▸ APIτʔΫϯΈ͍ͨͳͷ༻ҙ͢Δ ▸ Expireͱ͔ϦϑϨογϡͷΈ͕͍Δ ▸ ΕͨΒࠔΔ ▸ ܦ࿏͕҉߸Խ͞Ε͍ͯͨΒ·͍͍͋
▸ OAuth 2.0 ▸ ͏·͘Δํ๏͋Γͦ͏͚ͩΕͲݟͳ͠
҉߸Խ ಡԽ Ӆ͍ͨ͠ͷͰ
ؔϞό#9 ҉߸Խ,ಡԽ ▸ Ӆ͍ͨ͠ใΛӅ͢ ▸ ୈࡾऀʹରͯ͠(ݸਓใ)ɺ༻ऀʹରͯ͠ (ήʔϜͱ͔) ▸ HTTPSͩͱ͍͍ͩͨ҆৺ ▸
༰ΛಡԽͯ͠όΠφϦͰૹΔͱ͔ ▸ ΞϓϦଆͰσίʔυ͢Δͷେม ▸ σίϯύΠϧ͞Εͨͱ͖ͷରࡦ ▸ ૬खCIA͡Όͳͯ͘ૉਓ
όʔδϣϯ ޙํޓͷཁ
ؔϞό#9 όʔδϣϯ ▸ ޙํޓੑΛอ͍ͪͨ ▸ όʔδϣϯΛࢦఆ͢Δ͜ͱͰϨεϙϯεΛฦ͠Θ͚Δ ▸ /v1/hoge/piyo, ?version=1, X-API-Version:
1, application/ vnd.example.v1+json ▸ Ͳ͏ͬͯཧ͢Δ͔ ▸ ผͷϑΝΠϧͰཧ͢Δ ▸ ifจͰذ͢Δ ▸ ݹ͍όʔδϣϯΛ͍ͭഇࢭ͢Δ͔
ඇޓͳมߋ ආ͚ΒΕͳ͍
ؔϞό#9 ඇޓͳมߋ ▸ ਃͲ͏͢Δͷ͔ ▸ ਃ༻ͷαʔόʔΛ༻ҙͯͦͪ͠Βʹ͚Δ ▸ ΤϯυϙΠϯτΛฦ͢API (HATEOASʹͭͳ͕Δ) ▸
ਃ࣌ͷΈຊ൪ͱผͷͷݟͤΔͷͲ͏ͳͷ͔ ▸ ͪͳΈʹͯͳͰͬͯͳ͍ ▸ ڧ੍όʔδϣϯΞοϓ ▸ ΞϓϦͷόʔδϣϯΛ্͛ͳ͍ͱ͑ͳ͘͢Δ
ͦͷଞͷ
ؔϞό#9 ▸ υΩϡϝϯτ ▸ ςετ ▸ ΦʔέεϨʔγϣϯ ▸ ཉ͍͚ͩ͠Β͏ͱ͔
▸ ࣗಈੜ ▸ Swaggerͱ͔ ▸ ແݶʹ͋Δ
·ͱΊ ͦͯ͠
ؔϞό#9 ·ͱΊ ▸ ͑ͳ͍ ▸ ϓϩδΣΫτຖʹߟ͑Δඞཁ͕͋Δ ▸ ͱʹ͔͘໎͏ ▸ ձ͠·͠ΐ͏
ϝϦʔΫϦε Ϛε