HTTPX · API Governance Rules
HTTPX API Rules
Spectral linting rules defining API design standards and conventions for HTTPX.
0 Rules
Spectral Ruleset
x-aid: httpx:httpx-rules
x-name: HTTPX Rules
description: >-
Rules and guidelines for using the HTTPX Python HTTP client library
effectively in synchronous and asynchronous applications.
x-type: Rules
x-tags:
- Async
- HTTP Client
- Python
- Rules
rules:
- name: Reuse Clients
description: >-
Instantiate a single httpx.Client or httpx.AsyncClient and reuse it
across requests. Creating a new client per request wastes connection
pooling and TLS resources.
- name: Use Async Client For Concurrency
description: >-
Use httpx.AsyncClient inside async code paths. Mixing sync and async
transports inside the same event loop can block the loop and degrade
performance.
- name: Set Explicit Timeouts
description: >-
Always configure connect, read, write, and pool timeouts. HTTPX
enforces strict timeouts and the default may not match your service
level requirements.
- name: Verify TLS By Default
description: >-
Leave certificate verification enabled. Disable it only for trusted
development scenarios and never in production traffic.
- name: Stream Large Responses
description: >-
Use the stream interface for large response bodies to avoid loading
the entire payload into memory.
- name: Handle Redirects Explicitly
description: >-
Redirects are not followed by default. Enable follow_redirects when
you want requests behavior, and bound max_redirects to avoid loops.
- name: Use HTTP/2 When Beneficial
description: >-
Enable http2=True on the client when talking to HTTP/2 capable
origins for multiplexed performance gains. Install the http2 extra.
- name: Pin The Library Version
description: >-
Pin httpx in requirements files. The library is pre 1.0 in some
tracks and minor releases can introduce breaking changes.
x-maintainers:
- FN: Kin Lane
email: kin@apievangelist.com
Work with this as data
Every ruleset here is available over the APIs.io API and to AI agents over MCP.
MCP server
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
Tools for spectral rules
4 MCP tools reach this
find_rulesBrowse and filter every ruleset in the catalog.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.
Call it yourself
curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/httpx-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.