Interview Prep/Python for DevOps/Data formats, HTTP & REST APIs

`requests` vs `httpx` vs `aiohttp`: when would you pick each?

IntermediateConceptData formats, HTTP & REST APIs
Answer
  • requests: synchronous, ubiquitous, the default for scripts.
  • httpx: requests-like API with both sync and async clients, HTTP/2 support, strict timeouts by default (5s), and respx for mocking. A good choice if you might go async later.
  • aiohttp: async-only client and server, very mature, high throughput.

For a script calling 20 endpoints, requests. For 5,000 concurrent health checks, httpx async or aiohttp with a semaphore.

All Python for DevOps questions Roadmap: Python for automation

More on Data formats, HTTP & REST APIs