Designing Pythonic APIs
summary
Compares requests vs urllib-style APIs across five concrete use cases and shows why requests wins: top-level exports and explicit verbs make code shorter; response objects give a useful repr and a direct status_code attribute instead of a getter; error handling offers an optional raise_for_status instead of forcing exceptions; JSON support is baked in via a json= parameter; auth accepts plain Python types and sessions scale from one-off to persistent. Live code examples and a mock HTTP service prove each point.
AI-written summary · about
chapters (11)
- 0:00Introduction to Pythonic APIs
- 1:56Why good package interfaces matter
- 3:46Comparing requests and urllib
- 6:04Top-level imports and explicit methods
- 11:45Handling status codes
- 13:56Encapsulation with properties
- 15:26Error handling strategies
- 16:51Encoding and decoding requests
- 19:27Sending authenticated requests
- 24:53Python standard library vs third-party APIs
- 25:15Q&A and closing remarks
related talks
26mDesigning APIs with Flask
29mThe Complexity of Simplicity
46mOn Being Pythonic
24mA Lazy Person's Guide to Building REST Clients or: How I Learned to Stop Worrying and Love Dunder Ov
47mBuilding APIs your users will want to use
40mOh Python! Where Did We Go Wrong
24mPython for Humans, Designing Python Code Like a User Interface
01h 06mGood API design
