Backend Development 6 min read

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.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Introducing Niquests: A Modern Python HTTP Client with HTTP/1.1, HTTP/2, and HTTP/3 Support

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>&gt;&gt;&gt; import niquests
&gt;&gt;&gt; s = niquests.Session(resolver="doh+google://", multiplexed=True)
&gt;&gt;&gt; r = s.get('https://one.one.one.one')
&gt;&gt;&gt; r
&lt;ResponsePromise HTTP/3&gt;
&gt;&gt;&gt; r.status_code
200
&gt;&gt;&gt; r.headers['content-type']
'application/json; charset=utf8'
&gt;&gt;&gt; r.oheaders.content_type.charset
'utf8'
&gt;&gt;&gt; r.encoding
'utf-8'
&gt;&gt;&gt; r.text
'{"authenticated": true, ...'
&gt;&gt;&gt; r.json()
{'authenticated': True, ...}
&gt;&gt;&gt; r
&lt;Response HTTP/3 [200]&gt;
&gt;&gt;&gt; r.ocsp_verified
True
&gt;&gt;&gt; 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.

PythonHTTP/3HTTP ClientNiquestsRequests alternative
Python Programming Learning Circle
Written by

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.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.