Slide 1

Slide 1 text

Web API ׬શʹཧղͨ͠ ʙᴈ໌ฤʙ

Slide 2

Slide 2 text

@unsoluble_sugar
 TOPGATE, Inc. Leader/Engineer

Slide 3

Slide 3 text

Web API ׬શʹཧղͯ͠·͔͢ʁ

Slide 4

Slide 4 text

ฉ͍ͨ͜ͱ͋Δ
 ׬શʹཧղͨ͠ Կ΋Θ͔Βͳ͍ νϣοτσΩϧ

Slide 5

Slide 5 text

ฉ͍ͨ͜ͱ͋Δ
 ׬શʹཧղͨ͠ Կ΋Θ͔Βͳ͍ νϣοτσΩϧ

Slide 6

Slide 6 text

֓ཁ • ର৅͸ ฉ͍ͨ͜ͱ͋Δਓ • ׬શʹཧղͨ͠ঢ়ଶʹͳΔͨΊͷೖ໳ฤ • ࡉ͔͍આ໌͸ল͖·͢ • ෆ଍෦෼͸ॻ੶΍Webͷ৘ใͰิ׬ͯ͠Ͷ

Slide 7

Slide 7 text

Web APIͱ͸ʁ

Slide 8

Slide 8 text

Web APIͱ͸ • APIͱ͸ʮApplication Programming Interfaceʯͷུ • ֎෦͔ΒػೳΛར༻͢ΔͨΊͷ࢓૊Έ • HTTPϓϩτίϧΛ༻͍ͯɺωοτϫʔΫӽ͠ʹػೳΛݺͼग़͢ APIͷ͜ͱΛʮWeb APIʯͱݺͿ

Slide 9

Slide 9 text

ͲΜͳαʔϏεͰ࢖ΘΕͯΔͷʁ

Slide 10

Slide 10 text

Web API͕࢖ΘΕ͍ͯΔαʔϏε • GoogleɺAmazonɺTwitterɺFacebookɺetc… • ੈͷதʹ͸Web APIΛલఏͱͨ͠αʔϏε͕ᷓΕ͍ͯΔ
 χϡʔεɺఱؾɺ஍ਤɺSNSɺγϣοϐϯάɺήʔϜɺΤϯλϝͳͲͳͲ • αʔό௨৴Λߦ͏εϚϗΞϓϦͰ΋ར༻ • ެ։/ඇެ։ͷWeb API͕ଘࡏ

Slide 11

Slide 11 text

۩ମతʹ͸ʁ

Slide 12

Slide 12 text

Twitter APIͷ৔߹ • Twitter͸Web APIΛఏڙ͍ͯ͠Δ • ։ൃऀ͸Web APIΛར༻ͯ͠Twitterͷ༷ʑͳػೳ͕࢖͑Δ • ଟ͘ͷαʔυύʔςΟ੡ΫϥΠΞϯτ͕։ൃ͞Εൃల • ࠷ۙ͸࢖༻੍ݶ͕ݫ͍͠…

Slide 13

Slide 13 text

APIϦϑΝϨϯε https://developer.twitter.com/en/docs/api-reference-index
 
 
 
 
 
 


Slide 14

Slide 14 text

࢓༷ৄࡉ͕ެ։͞Ε͍ͯΔ ։ൃऀ͸APIΛ࢖ͬͯಠࣗͷΞϓϦ΍WebαʔϏεΛ࡞Δ͜ͱ͕Ͱ͖Δ
 
 
 
 
 
 
 


Slide 15

Slide 15 text

࣮ࡍͷAPIͷಈ͖͸ʁ

Slide 16

Slide 16 text

ϢʔβʔλΠϜϥΠϯऔಘ HTTPϝιου GET Ϩεϙϯεܗࣜ JSON υϝΠϯ https://api.twitter.com ΤϯυϙΠϯτ /1.1/statuses/user_timeline.json ύϥϝʔλ screen_name, count, include_rts, etc… ೝূ Bearer Token

Slide 17

Slide 17 text

APIϦΫΤετΛ౤͛Δͱ… $ curl "https://api.twitter.com/1.1/statuses/user_timeline.json? screen_name=unsoluble_sugar&count=10" -H "Authorization: Bearer " | jqɹ

Slide 18

Slide 18 text

λΠϜϥΠϯͷ৘ใ͕JSONͰऔಘͰ͖Δ { "created_at": "Sun Jan 19 12:33:32 +0000 2020", "id": 1218874129316638700, "id_str": "1218874129316638720", "text": "ϦΫΤετϔομʔͷAuthorizationͬͯɺ೔ຊޠͰදݱ͢Δͱʮೝূํࣜʯͱ͔Ͱྑ͍ͷ͔͠Β", }, "source": "TweetDeck", "user": { "id": 149069183, "id_str": "149069183", "name": "੕Ө", "screen_name": "unsoluble_sugar", "location": "ೋ࣍ݩ", "description": "Tech Hunter୅දɻશจݕࡧ/εϚϗήʔϜ/νϟοτbot/IoTͱ͔΍ͬͯΔࡶଟͳΤϯδχΞɻ࠷ۙ͸PM΋݉೚ɻFlutter/GCP/FirebaseษڧதɻΨδΣΦλͰΞχ ΦλͰήʔΦλɻྦྷܭ1000ສPVͷݸਓϒϩάӡӦɻ2ࣇͷύύɻຊ୨ɿhttps://t.co/kGyfPuFvIO", "url": "https://t.co/h7Iq47ug5Z", "entities": { "url": { "urls": [ { "url": "https://t.co/h7Iq47ug5Z", "expanded_url": "https://unsolublesugar.com", "display_url": "unsolublesugar.com", …

Slide 19

Slide 19 text

ϨεϙϯεσʔλΛղੳͯ͠ը໘ʹ൓ө • πΠʔτ৘ใ
 textɿΫι຾͍
 created_atɿSun Jan 19 12:33:32 +0000 2020
 sourceɿTweetDeck • Ϣʔβʔ৘ใ
 user.profile_image_urlɿhttp://pbs.twimg.com/profile_images/1109649870594293766/AQHwKd6N_normal.jpg
 user.nameɿ੕Ө
 user.screen_nameɿunsoluble_sugar


Slide 20

Slide 20 text

༷ʑͳ৘ใ͕APIͰऔಘͰ͖Δ • ϗʔϜλΠϜϥΠϯͷऔಘ
 GET statuses/home_timeline • ݸผπΠʔτͷऔಘ
 GET statuses/show/:id • Ϧετͷऔಘ
 GET lists/list • ϑΥϩϫʔ৘ใҰཡͷऔಘ
 GET followers/list

Slide 21

Slide 21 text

GETҎ֎͸σʔλͷੜ੒ɺߋ৽ɺ࡟আ • πΠʔτͷ౤ߘ
 POST statuses/update • ը૾ͷΞοϓϩʔυ
 POST media/upload • DMͷ࡟আ
 DELETE direct_messages/events/destroy • DMͷ΢ΣϧΧϜϝοηʔδมߋʢ͜Μͳػೳ͋ͬͨΜ͔…ʣ
 PUT direct_messages/welcome_messages/update

Slide 22

Slide 22 text

Twitter͸Web APIͰग़དྷ͍ͯΔ

Slide 23

Slide 23 text

Web API

Slide 24

Slide 24 text

׬શʹཧղͨ͠ʁ

Slide 25

Slide 25 text

• HTTPϔομʔɺϘσΟʢϦΫΤετɾϨεϙϯεʣ • HTTPϝιου • ΤϯυϙΠϯτ • ΫΤϦετϦϯάʢURLύϥϝʔλʔʣ • URLΤϯίʔσΟϯά • ϑΟϧλɺιʔτɺݕࡧɺϖʔδωʔγϣϯ • ೝূɺೝՄʢBasic, OAuth2, OpenID Connectʣ • ηογϣϯ؅ཧ • σʔλܕ • ग़ྗܗࣜʢJSON, XML, HTMLʣ • ΤϥʔϋϯυϦϯά • εςʔλείʔυʢ200, 404, 502ʣ • APIαʔόɺWebαʔό • όʔδϣϯ؅ཧ • ઃܭʢRESTfulʣ • ηΩϡϦςΟ

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

ࢀߟॻ੶ • WebΛࢧ͑Δٕज़ ᴷ HTTPɺURIɺHTMLɺͦͯ͠REST
 ࢁຊཅฏɹஶʢWEB+DB PRESS plusʣ
 2010೥4݄ ൃߦ
 • Web API: The Good Parts
 ਫ໺ و໌ɹஶʢΦϥΠϦʔδϟύϯʣ
 2014೥11݄ ൃߦ

Slide 28

Slide 28 text

Α͏ͦ͜
 Web API ͷੈք΁