Niquests 3.18 — 3 Years of Innovations in HTTP

Posted by Ousret@reddit | Python | View on Reddit | 82 comments

When I started working on Niquests, I dreamed about a "no-compromise" HTTP client, and three years later I finally made it to the end.

The end goal was, at least for me, to reach what the world of today allows us to, today. And, unfortunately the Python community is often stuck with decade old capabilities. (ie. http/1 only, legacy ssl capabilities, ...).

Niquests started as a fork of Requests in mid-2023. The motivation was simple: Requests is frozen, and millions of developers are stuck with a library that does not evolve (feature-wise). I didn't want to reinvent the wheel, the Requests interface is genuinely pleasant to work with. I just wanted to bring it up to speed with what modern HTTP looks like.

What changed in three years?

A lot. Here's some key things:

And it's fast, I mean really fast. In a real-world benchmark (details and reproduction steps in the README) sending 1000 requests to httpbingo.org/get:

Client Avg time to complete Protocol
httpx 2.087s HTTP/2
aiohttp 1.351s HTTP/1.1
niquests 0.551s HTTP/2

Migration starts as a one-liner. Replace import requests with import niquests as requests and you're done. We maintain backward compatibility with the Requests API. Your existing code, your .netrc, your auth flows, your cookie jars -- they all work. Even requests-mock, responses, betamax and similar third-party extensions are supported with minimal shims.

It's getting some real traction lately. We're about to cross the 100k pulls per day from PyPI alone, Niquests appearing more commonly in Github code search engine, and folks creating issues whether they found a bug or just to challenge the solution. That's excellent news!

It's been more than a decade since I started doing open source, and so far, it's nowhere near boring me. I'll answer the community as long as I possibly can.

What My Project Does

Niquests is a HTTP Client. It aims to continue and expand the well established Requests library. For many years now, Requests has been frozen. Being left in a vegetative state and not evolving, this blocked millions of developers from using more advanced features.

Target Audience

It is a production ready solution. So everyone is potentially concerned.

Comparison

Niquests is the only HTTP client capable of serving HTTP/1.1, HTTP/2, and HTTP/3 automatically. The project went deep into the protocols (early responses, trailer headers, etc...) and all related networking essentials (like DNS-over-HTTPS, advanced performance metering, etc..)

Project page: https://github.com/jawah/niquests