httpcore

A minimal, low-level HTTP client for Python with sync, async, and HTTP/2 support

Library
PyPI
v1.0.9
549 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
53 /100 Fair
Development Activity 0
Maintenance 44
Community 80
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 85
Code Quality 82
Innovation 78
Learning Curve 70

httpcore is the low-level networking engine underneath httpx, doing exactly one thing: sending HTTP requests over pooled, thread- and task-safe connections. It deliberately excludes the conveniences of a full client — no redirects, cookies, or JSON handling — so it can be reused as a clean transport layer by higher-level libraries.

It supports HTTP/1.1 and HTTP/2, HTTP(S) and SOCKS proxying, and both synchronous and asyncio/trio-based asynchronous interfaces generated from a single async codebase. Connection pooling, keep-alive expiry, and retry backoff are all built in, making it a solid foundation for anything that needs precise control over HTTP transport behavior.

What You Get

  • Thread-safe and task-safe connection pooling via ConnectionPool with configurable max connections, keep-alive limits, and expiry
  • Both synchronous (httpcore.request) and asynchronous (httpcore.AsyncConnectionPool) APIs generated from the same source via an internal async-to-sync unasync step
  • HTTP/1.1 and HTTP/2 support, including transparent ALPN-based protocol negotiation over TLS
  • HTTP(S) and SOCKS proxy support (HTTPProxy, AsyncSOCKSProxy) alongside direct connections
  • Pluggable NetworkBackend/AsyncNetworkBackend interfaces (sync, anyio, trio, and mock backends) so networking can be swapped or stubbed for testing
  • Configurable connection retries with exponential backoff and Unix domain socket support

Common Use Cases

  • Serving as the transport layer underneath httpx, which builds redirects, cookies, and content decoding on top of httpcore’s raw connection handling
  • Implementing a Python-based forward or reverse proxy service that needs direct, low-level control over connection pooling and protocol negotiation
  • Building custom HTTP client libraries or SDKs that need a lean, well-tested networking core rather than reimplementing socket and TLS handling from scratch
  • Writing test suites for HTTP-dependent code using MockBackend/AsyncMockBackend to simulate network responses without real sockets

Under The Hood

Architecture: httpcore is organized as a request pipeline: ConnectionPool (in httpcore/_sync/connection_pool.py and its async twin httpcore/_async/connection_pool.py) queues PoolRequest objects and hands each to an available HTTPConnection (httpcore/_sync/connection.py), which lazily opens a TCP or Unix socket via a NetworkBackend, negotiates TLS/ALPN, and then delegates to either HTTP11Connection or HTTP2Connection (httpcore/_sync/http11.py, http2.py) based on the negotiated protocol. httpcore/_models.py defines the URL, Origin, Request, and Response value objects that flow through this pipeline, and httpcore/_exceptions.py maps low-level socket/TLS errors onto a small, well-defined exception hierarchy (ConnectError, ReadTimeout, RemoteProtocolError, etc.) via a map_exceptions context manager. Every async module under httpcore/_async/ has a mechanically generated synchronous counterpart under httpcore/_sync/, so the sync and async APIs share identical logic and stay in lockstep.

Tech Stack: Pure Python 3.8+ with a deliberately tiny dependency footprint — certifi for CA bundles and h11>=0.16 for HTTP/1.1 parsing are the only hard requirements; h2 (HTTP/2), socksio (SOCKS proxying), anyio, and trio are all optional extras gated behind pip install httpcore[...]. The package builds with hatchling and hatch-fancy-pypi-readme, and pyproject.toml enables mypy --strict across the codebase.

Code Quality: The tests/ directory mirrors the source layout with tests/_sync/ and tests/_async/ suites covering connection_pool, connection, http11, http2, http_proxy, socks_proxy, plus an integration suite and a tests/benchmark/ client/server pair for throughput testing. Code favors small, single-responsibility classes (PoolRequest, HTTPConnection, HTTP11Connection) with explicit state machines for connection lifecycle (is_available, has_expired, is_idle, is_closed), consistent use of from __future__ import annotations and full type hints throughout, and strict mypy enforcement rather than relying on runtime checks alone.

API Design: The public surface is intentionally narrow — a handful of top-level functions (httpcore.request, httpcore.stream) for one-off calls, and ConnectionPool/AsyncConnectionPool as the primary reusable entry point, both implementing a shared RequestInterface. Docstrings on every public method spell out each parameter, and the sync/async API pairing (ConnectionPool vs AsyncConnectionPool, same method names and signatures) means developers can look up one and immediately use the other. The tradeoff is that consumers must understand HTTP at a lower level than with httpx — there’s no automatic redirect following or JSON decoding — which is by design given httpcore’s role as a transport primitive.

Used by 14 apps in this directory

Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 5 days ago
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,125

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
61
Dependency
Built with
Python 59%
Jupyter Notebook 21%
Updated 1 weeks ago
Python
97%
MIT

auto-news

AI Assistants · Productivity

908

An AI-powered personal news aggregator that filters multi-source feeds through LLMs and delivers curated, noise-free summaries to your Notion workspace.

View details
43
Repo Health
53
Technical
66
Dependency
Built with
Python 97%
Updated 1 years ago
C++
68%
Apache 2.0

ClickHouse

Analytics · Data Engineering · Databases

50,116

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
64
Dependency
Built with
C++ 68%
Python 14%
Updated 5 days ago
Go
32%
Apache 2.0

CubeSandbox

AI Agents · Developer Tools · Security

12,728

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
82
Repo Health
88
Technical
63
Dependency
Built with
Go 32%
Rust 26%
C 22%
Updated 1 weeks ago
Python
70%
Apache 2.0

GPT Researcher

AI Assistants · Productivity

29,650

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
91
Repo Health
91
Technical
63
Dependency
Built with
Python 70%
TypeScript 18%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 2 weeks ago
Python
86%
Apache 2.0

knowhere

AI Development · AI Memory · Developer Tools

3,541

Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.

View details
82
Repo Health
75
Technical
66
Dependency
Built with
Python 86%
HTML 14%
Updated 1 weeks ago
Go
67%
Apache 2.0

OSV.dev

Security

2,948

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
87
Repo Health
82
Technical
66
Dependency
Built with
Go 67%
Python 22%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers