Install & Compatibility
Where this runs
tested against v3.21.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.600s · 38MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.2s · import 0.584s · 37MB
36MB installed
● package 36MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
get
✓ import niquests
response = niquests.get('https://httpbin.org/get')
✗ import requests
response = requests.get('https://httpbin.org/get')
While Niquests is a drop-in replacement, directly using `niquests.get` ensures access to Niquests-specific features and avoids potential conflicts if `requests` is also installed.
post
✓ import niquests
response = niquests.post('https://httpbin.org/post', json={'key': 'value'})
Similar to `get`, direct import of `niquests` is recommended for new code.
Session
✓ from niquests import Session
session = Session()
✗ from requests import Session
session = Session()
Instantiate Niquests' `Session` object directly to utilize its enhanced features and thread-safety.
AsyncSession
✓ from niquests import AsyncSession
async_session = AsyncSession()
Use `AsyncSession` for asynchronous operations, which requires an `anyio` backend to be installed.
This quickstart demonstrates both synchronous and asynchronous HTTP requests using Niquests. It performs a simple GET request using the top-level API and a POST request using an `AsyncSession` for concurrent operations.
import niquests
import asyncio
def sync_example():
print('--- Sync Example ---')
response = niquests.get('https://httpbin.org/get')
response.raise_for_status()
print(f"Sync GET status: {response.status_code}")
print(f"Sync GET JSON: {response.json()['headers']['Host']}")
async def async_example():
print('\n--- Async Example ---')
async with niquests.AsyncSession() as session:
response = await session.post('https://httpbin.org/post', json={'test': 'data'})
response.raise_for_status()
print(f"Async POST status: {response.status_code}")
print(f"Async POST JSON: {response.json()['json']}")
if __name__ == '__main__':
sync_example()
asyncio.run(async_example())
Upgrade
Version history
3.21.1latest on PyPI · released Aug 28, 2026
Audit
Dependencies
httpcorerequiredCore underlying HTTP client library used by Niquests.
h11requiredHTTP/1.1 protocol implementation.
anyiooptionalRequired for async functionality (AsyncSession).
h2optionalEnables HTTP/2 protocol support.
brotlioptionalFor Brotli compression support.
zstandardoptionalFor Zstandard compression support.
rtlsoptionalAlternative TLS backend as disclosed in v3.18.3.