Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
APIクライアントを作ろう! / Let's make API client!
Search
papix
June 02, 2015
Technology
940
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
APIクライアントを作ろう! / Let's make API client!
papix
June 02, 2015
More Decks by papix
See All by papix
Houtou.pm #1
papix
0
2k
Perl歴約10年のエンジニアがフルスタックTypeScriptに出会ってみた
papix
1
790
YAPC::Kyotoの「全て」 / All of "YAPC::Kyoto"
papix
0
1.7k
イベントの中の人 / Inside the Events
papix
0
380
2022年に始めるPerlでWebサービス開発(趣味)
papix
0
660
ワーケーションに関する考察
papix
3
2.4k
(今更)Amplifyさっくり体験
papix
0
940
はてなにおけるGitHub Actions活用事例 / GitHub Actions in Hatena
papix
0
2.9k
ミススペルを発見するmisspellのご紹介 / Introduce misspell
papix
0
1.3k
Other Decks in Technology
See All in Technology
"AWSはちょっと苦手"でも大丈夫。AWS Blocks で手軽に作る Flutter のバックエンド #FlutterKaigi
tacck
PRO
0
110
re:Invent の去年のスケジュールを公開します!
miu_crescent
PRO
0
120
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
2
230
Draft AIエージェントの トークン消費を最小化する 8つの原則
kinopeee
6
1.9k
外国人エンジニアがVueプロトタイプで仕様を合わせている話 / Vue Fes Japan 2026 LT
eluwing
0
320
推論基盤と Scale-Up Interconnect の現状と制約から俯瞰する技術動向
markunet
2
660
クラウドエージェントの先駆け Devin。今も最先端を走る、他との違い
kinopeee
1
520
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
270
Technical Project Manager の役割とやりがい、少しだけ AI
yoshiiryo1
0
280
AI時代の開発はウォーターフォールに回帰する? / development-with-ai-back-to-wf
okamototakuyasr2
0
160
Vue で書く 空間コンピューティング、TresJS と WebXR を使ったXR デバイスのフロントエンド開発
hiranuma
0
130
AIテスト自動化と評価駆動開発EDD
happysamurai294
0
110
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Unsuck your backbone
ammeep
672
58k
The Limits of Empathy - UXLibs8
cassininazir
2
740
My Coaching Mixtape
mlcsv
0
370
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
750
Typedesign – Prime Four
hannesfritz
42
3.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
The Curious Case for Waylosing
cassininazir
1
590
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Transcript
APIクライアントを作ろう! by papix (GaiaX Co. Ltd.)
papix (GaiaX Co. Ltd.) R&D Div. Technical Basis Gr. •
Infrastructure Engineer • “Reactio” Engineer • Recruitment Officer • Perl Community Specialist • “Perl Entrance” headmaster PAPIX papix _̲_̲papix_̲_̲ takayuki.fukumoto.92 Masteries http://papix.hatenablog.com/ _̲_̲papix_̲_̲ papics (Free materials) ※18時50分現在
None
突然ですが…
APIクライアント
作ったことありますか?
APIクライアント • WebサービスのAPIを叩く君 – Twitter -‐‑‒> Net::Twitter – ImKayac -‐‑‒> WebService::ImKayac::Simple – Mackerel
-‐‑‒> WebService::Mackerel • Perlスクリプトからお⼿手軽にWebサービス を利利⽤用できてとても便便利利 • CPANにもいっぱい公開されている
https://reactio.jp/ 先⽇日リリースした 障害対応に特化した コミュニケーションツールという ⾃自社サービス
の
APIクライアントを作ったので
その時に得た(調べた)知⾒見見を 発表しようと思います
名前空間
APIクライアントでよく使われる 名前空間を紹介するぜ!!!
Net !!!
WebService !!!
WWW !!!
以上だ!!!!!
名前空間 • Net – Net::Twitter – Net::Travis::API ... • WebService – WebService::ImKayac::Simple – WebService::Livedoor::Weather
... • WWW – WWW::Twilio::API – WWW::NHKProgram::API ...
どれ使えばええねん!!!
https://pause.perl.org/pause/query?ACTION=pause_̲namingmodules#Net
Net / WebService / WWW • ネットワークプロトコル – Net • アプリケーションプロトコル
– WebService or WWW WebService or WWWが良良さそう!
依存ライブラリ
依存ライブラリ • 少ないに越したことはない – 「重い」ライブラリに依存するのは避けたい – 利利⽤用者から敬遠される可能性もある • 良良く使われるライブラリ – HTTP Client: LWP,
Furl, HTTP::Tiny ... – Decoder: JSON, XML::LibXML, XML::Simple ... – URI, Class::Accessor::Lite, Encode, Carp ...
依存ライブラリ • WebService::Simple – Web ServiceのClientを作る為のシンプルな フレームワーク(yusukebeさん製) – WebService::Simpleを継承して シンプルにクライアントを実装できる • 例例:
WebService::Simple::AWS ...
テスト
テスト • 「実際のAPIを叩く」テストを書くのはNG – ネットに繋がっていないとテストが通らない – テストする度度にWebサービスにアクセスが… • 1. 異異常ケースのテストを書く – パラメータが⾜足りない場合とか… – フォーマットが不不正な場合とか…
• 2. APIを叩く部分のmockを作る – 実際にAPIを叩かずにレスポンスを得る
Test::Mock::Guard • 任意のメソッドに対するモック
Test::Mock::Furl • Furlのモック – レスポンスを偽装できる – LWPならTest::Mock::LWPなど...
気をつけるべきところ • ドキュメント – Synopsisで利利⽤用例例を⽰示す – 使えるメソッドやその使い⽅方を⽰示しておく • サンプルコード – 「eg」ディレクトリに配置すれば サンプルコードとして扱ってくれる(MetaCPAN)
さいごに
APIクライアント作っていこう! • 昨今様々なサービスが開発されている • API ClientがCPANにないものもある – 愛⽤用しているサービスのAPI Clientがないので あれば, 作っていこう!
• みんながお得!!! – ⾃自分も便便利利 – サービス利利⽤用者も便便利利 – サービス提供者も嬉しい
おわり ご静聴ありがとうございました!