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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ReST APIs @ PyCon India, 2015
Devi
October 03, 2015
More Decks by Devi
See All by Devi
Understanding ElasticSearch
asldevi
0
120
Logging the right way!
asldevi
2
310
Growing with communities
asldevi
0
92
Observability at scale
asldevi
0
210
We shall overcome - gender gap in tech
asldevi
1
470
How to kickstart your (technical) career
asldevi
0
80
Testing micro-services made easy @ PyCon 2018
asldevi
1
440
Growing with ElasticSearch
asldevi
0
110
Web development - Code to Deployment
asldevi
1
700
Other Decks in Technology
See All in Technology
中期計画、2回作ってみた ~業務委託と正社員、両方の視点から~
demaecan
1
680
20260619 私の日常業務での生成 AI 活用
masaruogura
1
130
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
840
チームで進めるAI駆動アジャイル×ウォーターフォール
kumaiu
0
150
protovalidate-es を導入してみた
bengo4com
0
170
How Timee Delivers Day 1 Production Ready LLM Features
tomoyks
0
140
Microsoft Build Keynoteふりかえり
tomokusaba
0
120
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
150
やさしいA2A入門
minorun365
PRO
12
1.7k
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
1
230
機械学習を「社会実装」するということ 2026年夏版 / Social Implementation of Machine Learning June 2026 Version
moepy_stats
4
1.6k
自宅LLMの話
jacopen
1
400
Featured
See All Featured
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
420
Deep Space Network (abreviated)
tonyrice
0
170
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
How to build a perfect <img>
jonoalderson
1
5.6k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
How to Talk to Developers About Accessibility
jct
2
230
So, you think you're a good person
axbom
PRO
2
2.1k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
610
The Invisible Side of Design
smashingmag
302
52k
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