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
HTTP API & Python
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Milan Cermak
February 20, 2013
Programming
3
280
HTTP API & Python
Slides from my talk at Brno and Prague Python user group meetups on HTTP/REST APIs.
Milan Cermak
February 20, 2013
Tweet
Share
More Decks by Milan Cermak
See All by Milan Cermak
Building a CI/CD pipeline on AWS
milancermak
0
6.3k
Designing mobile friendly APIs
milancermak
0
120
Programování pro iOS z pohledu pythonistu
milancermak
0
280
Prečo povedať nie SQL
milancermak
1
130
Other Decks in Programming
See All in Programming
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.2k
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
260
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
280
Python札幌 LT資料
t3tra
7
1.1k
Basic Architectures
denyspoltorak
0
630
ELYZA_Findy AI Engineering Summit登壇資料_AIコーディング時代に「ちゃんと」やること_toB LLMプロダクト開発舞台裏_20251216
elyza
2
1.3k
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.8k
Grafana:建立系統全知視角的捷徑
blueswen
0
310
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
560
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
170
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
430
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
190
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.4k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
390
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Deep Space Network (abreviated)
tonyrice
0
36
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
150
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
240
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
75
GitHub's CSS Performance
jonrohan
1032
470k
Transcript
HTTP API & Py Milan Čermák Pyvo Praha, 20. 2.
2013 Wednesday, February 20, 13
What makes a good API? Wednesday, February 20, 13
Wednesday, February 20, 13
Consistency Wednesday, February 20, 13
Consistency Predictability Wednesday, February 20, 13
Consistency Predictability Adherence to standards Wednesday, February 20, 13
Consistency Predictability Adherence to standards Great documentation Wednesday, February 20,
13
Why HTTP? Wednesday, February 20, 13
"While HTTP isn’t always the best answer, it’s a damn
fine first guess." Coda Hale Wednesday, February 20, 13
Benefits of HTTP Wednesday, February 20, 13
Benefits of HTTP The most widespread application protocol Wednesday, February
20, 13
Benefits of HTTP The most widespread application protocol Statelessness Wednesday,
February 20, 13
Benefits of HTTP The most widespread application protocol Statelessness Optional
caching Wednesday, February 20, 13
Benefits of HTTP The most widespread application protocol Statelessness Optional
caching Promotes layered infrastructure Wednesday, February 20, 13
Benefits of HTTP The most widespread application protocol Statelessness Optional
caching Promotes layered infrastructure etc. Wednesday, February 20, 13
Limitations of HTTP Wednesday, February 20, 13
Limitations of HTTP Authorization Wednesday, February 20, 13
Limitations of HTTP Authorization Statelessness Wednesday, February 20, 13
Limitations of HTTP Authorization Statelessness Verbosity Wednesday, February 20, 13
Limitations of HTTP Authorization Statelessness Verbosity Crippled parallelism Wednesday, February
20, 13
"REST" if protocol.startswith("http") else "you're doing it wrong" Wednesday, February
20, 13
Set of architectural constraints Wednesday, February 20, 13
Set of architectural constraints Client-server Wednesday, February 20, 13
Set of architectural constraints Client-server Stateless Wednesday, February 20, 13
Set of architectural constraints Client-server Stateless Cacheable Wednesday, February 20,
13
Set of architectural constraints Client-server Stateless Cacheable Layered Wednesday, February
20, 13
Set of architectural constraints Client-server Stateless Cacheable Layered Uniform interface
* Wednesday, February 20, 13
How can Python help? Wednesday, February 20, 13
OOP Wednesday, February 20, 13
OOP URI ~ Class handler mapping Wednesday, February 20, 13
import handlers urls = [(r"/user", handlers.users.NewUser), (r"/user/(\d+)", handlers.users.User)] class User(handler.base.BaseHandler):
def delete(self, user_id): pass def get(self, user_id): pass def post(self, user_id): pass Wednesday, February 20, 13
class UserValidatorMixin(object): def check_user_data(self, user_dict): pass class User(handler.base.BaseHandler, UserValidatorMixin): def
post(self, user_id): new_user = self.get_argument(“user”) if not self.check_user_data(new_user): return self.http_error(400, “Invalid data”) Wednesday, February 20, 13
Middleware Wednesday, February 20, 13
Wednesday, February 20, 13
Extending JSONEncoder Wednesday, February 20, 13
import json class AppJSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, User):
return {"name": obj.name, "height": obj.height, "cash": obj.get_bank_account_balance()} return json.JSONEncoder.default(self, obj) user = User("1337") json.dumps(user, cls=AppJSONEncoder) Wednesday, February 20, 13
What about mobile? Wednesday, February 20, 13
Compression of HTTP bodies GET /user/1337 HTTP/1.1 Host: api.napyvo.io Accept-Encoding:
gzip, identity Wednesday, February 20, 13
Compression of HTTP bodies HTTP/1.1 200 OK Content-Encoding: gzip Content-Type:
application/json; charset=utf-8 Wednesday, February 20, 13
Compression of HTTP bodies POST /user HTTP/1.1 Host: api.napyvo.io Content-Encoding:
gzip Content-Type: application/json [gzipped representation of a user] Wednesday, February 20, 13
Caching Cache-Control: max-age=3600 Expires: Thu, 31 Jan 2013 22:00:00 GMT
<- Last-Modified: Thu, 31 Jan 2013 18:30:00 GMT -> If-Modified-Since: Wed, 30 Jan 2013 13:37:00 GMT ETag: foo If-None-Match: foo Wednesday, February 20, 13
Partial resources Wednesday, February 20, 13
GET /car/9 {"car": { "color": "red", "passengers": [ {"href": "/user/1337",
"rel": "self"}] } } Wednesday, February 20, 13
GET /car/9?zoom=passengers {"car": { "color": "red", "passengers": [ {"href": "/user/1337",
"rel": "self", "name": "Milan", "drink": "beer", "skills": ["python", "http"], }] } } Wednesday, February 20, 13
The promise of Hypermedia Wednesday, February 20, 13
Hypermedia as the engine of application state Wednesday, February 20,
13
Q & A Wednesday, February 20, 13