{"id":3175,"library":"niquests","title":"Niquests HTTP Library","description":"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.","status":"active","version":"3.18.5","language":"en","source_language":"en","source_url":"https://github.com/jawah/niquests","tags":["http","networking","requests-alternative","async","web"],"install":[{"cmd":"pip install niquests","lang":"bash","label":"Install Niquests"}],"dependencies":[{"reason":"Core underlying HTTP client library used by Niquests.","package":"httpcore","optional":false},{"reason":"HTTP/1.1 protocol implementation.","package":"h11","optional":false},{"reason":"Required for async functionality (AsyncSession).","package":"anyio","optional":true},{"reason":"Enables HTTP/2 protocol support.","package":"h2","optional":true},{"reason":"For Brotli compression support.","package":"brotli","optional":true},{"reason":"For Zstandard compression support.","package":"zstandard","optional":true},{"reason":"Alternative TLS backend as disclosed in v3.18.3.","package":"rtls","optional":true}],"imports":[{"note":"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.","wrong":"import requests\nresponse = requests.get('https://httpbin.org/get')","symbol":"get","correct":"import niquests\nresponse = niquests.get('https://httpbin.org/get')"},{"note":"Similar to `get`, direct import of `niquests` is recommended for new code.","symbol":"post","correct":"import niquests\nresponse = niquests.post('https://httpbin.org/post', json={'key': 'value'})"},{"note":"Instantiate Niquests' `Session` object directly to utilize its enhanced features and thread-safety.","wrong":"from requests import Session\nsession = Session()","symbol":"Session","correct":"from niquests import Session\nsession = Session()"},{"note":"Use `AsyncSession` for asynchronous operations, which requires an `anyio` backend to be installed.","symbol":"AsyncSession","correct":"from niquests import AsyncSession\nasync_session = AsyncSession()"}],"quickstart":{"code":"import niquests\nimport asyncio\n\ndef sync_example():\n    print('--- Sync Example ---')\n    response = niquests.get('https://httpbin.org/get')\n    response.raise_for_status()\n    print(f\"Sync GET status: {response.status_code}\")\n    print(f\"Sync GET JSON: {response.json()['headers']['Host']}\")\n\nasync def async_example():\n    print('\\n--- Async Example ---')\n    async with niquests.AsyncSession() as session:\n        response = await session.post('https://httpbin.org/post', json={'test': 'data'})\n        response.raise_for_status()\n        print(f\"Async POST status: {response.status_code}\")\n        print(f\"Async POST JSON: {response.json()['json']}\")\n\nif __name__ == '__main__':\n    sync_example()\n    asyncio.run(async_example())\n","lang":"python","description":"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."},"warnings":[{"fix":"Review Niquests' release notes and documentation for specific behavioral changes. Adjust `Session` parameters like `keepalive_delay` if needed to match previous Requests' behavior.","message":"While Niquests is a drop-in replacement for Requests, subtle behavioral differences may exist. For instance, the default `keepalive_delay` was lowered from 1 hour to 10 minutes in v3.18.3, which can affect long-lived connections.","severity":"gotcha","affected_versions":">=3.18.3"},{"fix":"Upgrade to Niquests v3.18.4 or later to ensure correct type behavior and compatibility with code expecting Requests' internal structure.","message":"Compatibility issues for `isinstance` checks relying on `niquests.packages` were present in earlier versions, leading to potential type-checking failures. This was fixed in v3.18.4, but suggests reliance on internal `requests`-like structure can be brittle.","severity":"gotcha","affected_versions":"<3.18.4"},{"fix":"Consult Niquests' documentation for WASM environment setup and ensure all prerequisites, including JSPI, are met for successful execution in WebAssembly contexts. Treat as experimental functionality.","message":"Experimental features like WebAssembly (WASM) support introduced in v3.18.0 require specific environments (e.g., Chrome v137+, Firefox v131+, Node v22+) and often require enabling JavaScript Promise Integration (JSPI) explicitly.","severity":"gotcha","affected_versions":">=3.18.0"},{"fix":"Refer to Niquests' documentation for detailed installation instructions and dependency requirements for specific advanced features.","message":"Advanced features such as the `rtls` alternative TLS backend (v3.18.3) or native `http+unix` connections (v3.17.0) may require additional `pip install` dependencies or specific environmental configurations beyond the basic `niquests` install.","severity":"gotcha","affected_versions":">=3.17.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}