Introducing Niquests: A Modern Python HTTP Client with HTTP/1.1, HTTP/2, and HTTP/3 Support
Niquests is a Python HTTP client that serves as a direct replacement for Requests, offering automatic support for HTTP/1.1, HTTP/2, and HTTP/3, along with advanced features such as DNS-over-HTTPS, async/await usage, and extensive security and performance enhancements.
Niquests is a simple and elegant HTTP client for Python, positioned as a direct replacement for the stagnant Requests library. It uniquely provides automatic support for HTTP/1.1, HTTP/2, and HTTP/3, and incorporates advanced networking capabilities such as DNS‑over‑HTTPS, high‑performance metrics, and robust security features.
Installation
Niquests is available on PyPI and officially supports Python or PyPy 3.7+.
<code>$ python -m pip install niquests</code>Basic Usage
<code>>>> import niquests
>>> s = niquests.Session(resolver="doh+google://", multiplexed=True)
>>> r = s.get('https://one.one.one.one')
>>> r
<ResponsePromise HTTP/3>
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.oheaders.content_type.charset
'utf8'
>>> r.encoding
'utf-8'
>>> r.text
'{"authenticated": true, ...'
>>> r.json()
{'authenticated': True, ...}
>>> r
<Response HTTP/3 [200]>
>>> r.ocsp_verified
True
>>> r.conn_info.established_latency
datetime.timedelta(microseconds=38)</code>You can also use async/await:
<code>import niquests
import asyncio
async def main() -> None:
async with niquests.AsyncSession(resolver="doh+google://") as s:
r = await s.get('https://one.one.one.one', stream=True)
print(r) # Output: <Response HTTP/3 [200]>
payload = await r.json()
print(payload) # Output: {'authenticated': True, ...}
asyncio.run(main())</code>Niquests makes sending HTTP requests effortless without manually constructing query strings or form‑encoding data; it also avoids mandatory compilation toolchains and only enables HTTP/3 when the platform natively supports it.
Supported Features and Best Practices
Niquests is ready to meet the demands of building scalable, robust, and reliable HTTP applications.
HTTPS‑based DNS, QUIC‑based DNS, TLS‑based DNS, UDP‑based DNS
Automatic content decompression and decoding
OS truststore by default, no longer requires certifi
OCSP certificate revocation verification
Advanced connection timing checks
Memory certificates (CA and mTLS)
Browser‑style TLS/SSL verification
Session with cookie persistence
Keep‑Alive & connection pooling
International domains and URLs
Automatic .netrc compliance
Basic and digest authentication
Familiar Cookiedict
Fine‑grained network settings
Prior‑knowledge HTTP/2
Object‑oriented headers
Multipart file uploads
Post‑quantum security
Chunked HTTP requests
Full type annotations
SOCKS proxy support
Connection timeouts
Streaming downloads
HTTP/2 by default
QUIC‑based HTTP/3
Early responses
Happy eyeballs
Reuse
Thread‑safe
WebSocket support
Trailers
DNSSEC
Asynchronous operation
Server‑Sent Events (SSE)
After reviewing the extensive feature list, Niquests appears to be a comprehensive replacement for Requests, inviting developers to try it out.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.