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
77
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
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
380
クラウドネイティブな開発 ~ 認知負荷に立ち向かうためのコンテナ活用
literalice
0
140
AI時代における技術的負債への取り組み
codenote
1
1.6k
弁護士ドットコム株式会社 エンジニア職向け 会社紹介資料
bengo4com
1
160
AWS DevOps Agentはチームメイトになれるのか?/ Can AWS DevOps Agent become a teammate
kinunori
6
750
AzureのIaC管理からログ調査まで、随所に役立つSkillsとCustom-Instructions / Boosting IaC and Log Analysis with Skills
aeonpeople
0
240
はじめての MagicPod生成AI機能 機能紹介から活用方法まで
magicpod
0
110
社内エンジニア勉強会の醍醐味と苦しみ/tamadev
nishiuma
0
230
20260428_Product Management Summit_tadokoroyoshiro
tadokoro_yoshiro
6
6.8k
20260423_執筆の工夫と裏側 技術書の企画から刊行まで / From the planning to the publication of technical book
nash_efp
3
420
ServiceNow Knowledge 26 の歩き方
manarobot
0
120
生成AIが変える SaaS の競争原理と弁護士ドットコムのプロダクト戦略
bengo4com
1
1.4k
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
800
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
170
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
370
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Visualization
eitanlees
150
17k
Are puppies a ranking factor?
jonoalderson
1
3.3k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
530
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
54k
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
Claude Code のすすめ
schroneko
67
220k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
170
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