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
ReST APIs @ PyCon India, 2015
Search
Devi
October 03, 2015
Technology
600
1
Share
ReST APIs @ PyCon India, 2015
Devi
October 03, 2015
More Decks by Devi
See All by Devi
Understanding ElasticSearch
asldevi
0
110
Logging the right way!
asldevi
2
310
Growing with communities
asldevi
0
90
Observability at scale
asldevi
0
200
We shall overcome - gender gap in tech
asldevi
1
460
How to kickstart your (technical) career
asldevi
0
78
Testing micro-services made easy @ PyCon 2018
asldevi
1
430
Growing with ElasticSearch
asldevi
0
100
Web development - Code to Deployment
asldevi
1
690
Other Decks in Technology
See All in Technology
2026年春のAgentCoreアプデ 細かいやつ全部まとめ
minorun365
3
220
[Scram Fest Niigata2026]Quality as Code〜AIにQAの思考を再現させる試み〜
masamiyajiri
1
300
「背中を見て育て」からの卒業 〜専門技術としてのテスト設計を軸に、品質保証のバトンを繋ぐ〜 #genda_tech_talk
nihonbuson
PRO
2
1.1k
そのSLO 99.9%、本当に必要ですか? 〜優先度付きSLOによる責任共有の設計思想〜 / Is that 99.9% SLO really necessary? Design philosophy of shared responsibility through prioritized SLOs
vtryo
0
500
AI飲み会幹事エージェントを作っただけなのに
ykimi
0
120
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
100k
10サービス以上のメール到達率改善を地道に継続的に進めている話 / Continue to improve email delivery rates across multiple services
yamaguchitk333
4
260
サービスの信頼性を高めるため、形骸化した「プロダクションミーティング」を立て直すまでの取り組み
stefafafan
1
260
ハーネスエンジニアリング入門
hatyibei
0
120
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
370
PdM・Eng・QAで進めるAI駆動開発の現在地/aidd-with-pdm-eng-qa
shota_kusaba
0
170
Building a Study Buddy AI Agent from Scratch: From Passive Chatbots to Autonomous Systems
itchimonji
0
150
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Become a Pro
speakerdeck
PRO
31
5.9k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
500
Done Done
chrislema
186
16k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How to Talk to Developers About Accessibility
jct
2
190
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The Curse of the Amulet
leimatthew05
1
12k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
170
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Transcript
ReST APIs What, Why and How? A. S. L. Devi
PyCon India, 2015
What is an API programmable interface (to web services) Specifies
the request and response formats for the communication between a client and a server.
Why? • Public APIs - services through API - glues
best of several languages / technologies - AWS, Stripe, ElasticSearch, Twitter, GrapheneDB etc • Private APIs - same service offered in different UIs - a mobile app, a web app, desktop app - Slack, FaceBook etc
• Resources • URLs (Uniform Resource Locators) • HTTP -
methods and response codes ReST - Representational State Transfer
Each resource is identified by a URL. /customers /customers/5 /customers/5/orders
/customers/5/orders/42 /customers/5/orders?completed=true /customers/5/orders?completed=true&page=1 ReST - Resources
ReST - HTTP Verbs • GET - Retrieve a resource
• POST - Create a resource • PUT - Create/update a resource • DELETE - Delete a resource GET, PUT and DELETE are idempotent.
• simple • consistent across - one way of doing
things • backward compatible • HATEOS - linked documents • Well documented :) How should a ReST API be?
* taken from “Building Web APIs with Flask” with thanks
to Miguel Grinberg
$ curl -XGET http://api.x.com/v1/customers HTTP/1.1 200 OK Content-Type: application/json {
"customers": [] } $ curl -XGET http://api.x.com/v1/customers/1 { “name”: “Alice”, “links”: { “orders”: http://api.x.com/customers/1/orders “self”: http://api.x.com/customers/1 }} CRUD: Create Read Update Delete $ curl -XPOST http://api.x.com/v1/customers - d “name=Alice” HTTP/1.1 201 CREATED Content-Type: application/json Location: http://api.x.com/ customers/1 {} $ curl -XPUT http://api.x.com/v1/customers/1 -d “name=Bob” HTTP/1.1 200 OK $ http DELETE http://api.x.com/customers/1 HTTP/1.1 204 No Content
HATEOS - Linked documents $ curl -XGET http://api.x.com/v1/customers/1 { “name”:
“Alice”, “links”: { “self”: “http://api.x.com/v1/customers/1, “orders”: “http://api.x.com/v1/customers/1/orders”, } }
More HATEOS $ curl -XGET http://api.x.com/v1/customers/1/orders/10 { “links”: { “self”:
“http://api.x.com/v1/orders/10”, “customer”: “http://api.x.com/v1/customers/1” }, “orders”: [{ “date”: 2015-01-01-00:00:09Z, “items”: [ {“quantity”: 2, “product”: “XXX-1”}, {“quantity”: 3, “product”: “XYY-42”}, ] ]} }
How to choose a library to build ReST API •
Data validation • Authentication & Authorization • Not tightly coupled with ORM or database • Pagination, rate limits, filters etc.
Authentication & Authorization - no assumptions of the client side
- global authentication - Authorization header - Basic Authentication - Token-Based - HMAC based
• http://restful-api-design.readthedocs.org/en/latest/ • http://restcookbook.com/ • http://player.oreilly.com/videos/9781491911938 • http://jsonapi.org References
Questions
Thank You ! @asldevi