httpcore

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
54/100Fair
Development Activity4
Maintenance44
Community80
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture85
Code Quality82
Innovation78
Learning Curve70

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

Devops · AI Development · Automation

41,774

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

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

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
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
97%
MIT

auto-news

AI Assistants · Productivity

906

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
Python97%
Updated 1 years ago
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

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
68
Dependency
Built with
C++69%
Python13%
Updated today
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

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
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
Python
63%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,039

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
88
Repo Health
91
Technical
64
Dependency
Built with
Python63%
TypeScript23%
Updated 1 months ago
TypeScript
91%
Apache 2.0

Helicone

Monitoring · AI Development · Analytics

6,083

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
62
Repo Health
81
Technical
66
Dependency
Built with
TypeScript91%
Updated 3 days ago
Python
83%
Apache 2.0

knowhere

AI Development · Developer Tools

2,515

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

View details
83
Repo Health
75
Technical
70
Dependency
Built with
Python83%
HTML16%
Updated today
Go
56%
Apache 2.0

OSV.dev

Security

2,888

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
90
Repo Health
82
Technical
70
Dependency
Built with
Go56%
Python32%
Updated today

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

Search