Niquests HTTP Library

3.18.5 · active · verified Sat Apr 11

Niquests is a simple, yet elegant, HTTP library designed as a drop-in replacement for Requests, which is currently under feature freeze. It aims to extend Requests' capabilities with modern features like async support, ASGI/WSGI integration, and experimental WebAssembly compatibility. The current version is 3.18.5, and it maintains an active release cadence with frequent updates.

Warnings

Install

Imports

Quickstart

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())

view raw JSON →