{"id":13501194,"url":"https://github.com/jawah/niquests","last_synced_at":"2025-03-29T08:32:13.884Z","repository":{"id":188065016,"uuid":"664365139","full_name":"jawah/niquests","owner":"jawah","description":"“Safest, Fastest, Easiest, and Most advanced” Python HTTP Client. Production Ready! Drop-in replacement for Requests.","archived":false,"fork":true,"pushed_at":"2024-05-22T05:50:55.000Z","size":13085,"stargazers_count":751,"open_issues_count":1,"forks_count":16,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-23T06:03:36.223Z","etag":null,"topics":["async","asyncio","certificate-revocation","dns-over-https","dns-over-quic","dns-over-tls","dnssec","doh","doq","happy-eyeballs","http","http-client","http2","http3","multiplexed","ocsp","python","quic","requests"],"latest_commit_sha":null,"homepage":"https://niquests.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"psf/requests","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jawah.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"custom":["https://www.python.org/psf/sponsorship/"]}},"created_at":"2023-07-09T18:50:41.000Z","updated_at":"2024-05-27T11:40:48.122Z","dependencies_parsed_at":"2023-09-22T11:16:01.073Z","dependency_job_id":"709b4ab5-febe-4f0c-bec4-12912bb0c957","html_url":"https://github.com/jawah/niquests","commit_stats":null,"previous_names":["jawah/niquests"],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawah%2Fniquests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawah%2Fniquests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawah%2Fniquests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jawah%2Fniquests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jawah","download_url":"https://codeload.github.com/jawah/niquests/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162092,"owners_count":20733351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","asyncio","certificate-revocation","dns-over-https","dns-over-quic","dns-over-tls","dnssec","doh","doq","happy-eyeballs","http","http-client","http2","http3","multiplexed","ocsp","python","quic","requests"],"created_at":"2024-07-31T22:01:28.808Z","updated_at":"2025-03-29T08:32:13.877Z","avatar_url":"https://github.com/jawah.png","language":"Python","funding_links":["https://www.python.org/psf/sponsorship/","https://tidelift.com/subscription/pkg/pypi-niquests?utm_source=pypi-niquests\u0026utm_medium=readme","https://github.com/sponsors/Ousret"],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/9326700/282852138-160f32e9-e6cf-495f-b39d-99891602acf9.png\" alt=\"Niquests Logo\"/\u003e\n\u003c/div\u003e\n\n**Niquests** is a simple, yet elegant, HTTP library. It is a drop-in replacement for **Requests**, which is under feature freeze.\n\nNiquests, is the “**Safest**, **Fastest[^10]**, **Easiest**, and **Most advanced**” Python HTTP Client. Production Ready!\n\n✔️ **Try before you switch:** [See Multiplexed in Action](https://replit.com/@ahmedtahri4/Python#main.py)\u003cbr\u003e\n📖 **See why you should switch:** [Read about 10 reasons why](https://medium.com/@ahmed.tahri/10-reasons-you-should-quit-your-http-client-98fd4c94bef3), and [\"_Revived the promise made six years ago for Requests 3_\"](https://medium.com/@ahmed.tahri/revived-the-promise-made-six-years-ago-for-requests-3-37b440e6a064)\u003cbr\u003e\n✨ **You were used to betamax, requests-mock, responses, ...?** [See how they still work! We got you covered.](https://niquests.readthedocs.io/en/latest/community/extensions.html)\n\n\u003cdetails\u003e\n  \u003csummary\u003e👆 \u003cb\u003eLook at the feature table comparison\u003c/b\u003e against \u003ci\u003erequests, httpx and aiohttp\u003c/i\u003e!\u003c/summary\u003e\n\n| Feature                                    |    niquests    | requests  |     httpx     | aiohttp       |\n|--------------------------------------------|:--------------:|:---------:|:-------------:|---------------|\n| `HTTP/1.1`                                 |       ✅        |     ✅     |       ✅       | ✅             |\n| `HTTP/2`                                   |       ✅        |     ❌     |     ✅[^7]     | ❌             |\n| `HTTP/3 over QUIC`                         |       ✅        |     ❌     |       ❌       | ❌             |\n| `Synchronous`                              |       ✅        |     ✅     |       ✅       | _N/A_[^1]     |\n| `Asynchronous`                             |       ✅        |     ❌     |       ✅       | ✅             |\n| `Thread Safe`                              |       ✅        |     ✅     |     ❌[^5]     | _N/A_[^1]     |\n| `Task Safe`                                |       ✅        | _N/A_[^2] |       ✅       | ✅             |\n| `OS Trust Store`                           |       ✅        |     ❌     |       ❌       | ❌             |\n| `Multiplexing`                             |       ✅        |     ❌     | _Limited_[^3] | ❌             |\n| `DNSSEC`                                   |     ✅[^11]     |     ❌     |       ❌       | ❌             |\n| `Customizable DNS Resolution`              |       ✅        |     ❌     |       ❌       | ✅             |\n| `DNS over HTTPS`                           |       ✅        |     ❌     |       ❌       | ❌             |\n| `DNS over QUIC`                            |       ✅        |     ❌     |       ❌       | ❌             |\n| `DNS over TLS`                             |       ✅        |     ❌     |       ❌       | ❌             |\n| `Multiple DNS Resolver`                    |       ✅        |     ❌     |       ❌       | ❌             |\n| `Network Fine Tuning \u0026 Inspect`            |       ✅        |     ❌     | _Limited_[^6] | _Limited_[^6] |\n| `Certificate Revocation Protection`        |       ✅        |     ❌     |       ❌       | ❌             |\n| `Session Persistence`                      |       ✅        |     ✅     |       ✅       | ✅             |\n| `In-memory Certificate CA \u0026 mTLS`          |       ✅        |     ❌     | _Limited_[^4] | _Limited_[^4] |\n| `SOCKS 4/5 Proxies`                        |       ✅        |     ✅     |       ✅       | ❌             |\n| `HTTP/HTTPS Proxies`                       |       ✅        |     ✅     |       ✅       | ✅             |\n| `TLS-in-TLS Support`                       |       ✅        |     ✅     |       ✅       | ✅             |\n| `Direct HTTP/3 Negotiation`                |     ✅[^9]      |  N/A[^8]  |    N/A[^8]    | N/A[^8]       |\n| `Happy Eyeballs`                           |       ✅        |     ❌     |       ❌       | ✅             |\n| `Package / SLSA Signed`                    |       ✅        |     ❌     |       ❌       | ✅             |\n| `HTTP/2 with prior knowledge (h2c)`        |       ✅        |     ❌     |       ✅       | ❌             |\n| `Post-Quantum Security`                    | _Limited_[^12] |     ❌     |       ❌       | ❌             |\n| `HTTP Trailers`                            |       ✅        |     ❌     |       ❌       | ❌             |\n| `Early Responses`                          |       ✅        |     ❌     |       ❌       | ❌             |\n| `WebSocket over HTTP/1`                    |       ✅        |  ❌[^14]   |    ❌[^14]     | ✅             |\n| `WebSocket over HTTP/2 and HTTP/3`         |     ✅[^13]     |     ❌     |       ❌       | ❌             |\n| `Automatic Ping for HTTP/2+`               |       ✅        |    N/A    |       ❌       | N/A           |\n| `Automatic Connection Upgrade / Downgrade` |       ✅        |    N/A    |       ❌       | N/A           |\n| `Server Side Event (SSE)`                  |       ✅        |     ❌     |       ❌       | ❌             |\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e📈 \u003cb\u003eLook at the performance comparison\u003c/b\u003e against \u003ci\u003ethem\u003c/i\u003e!\u003c/summary\u003e\n\n_Scenario:_ Fetch a thousand requests using 10 tasks or threads, each with a hundred requests using a single pool of connection.\n\n**High-Level APIs**\n\n| Client   | Average Delay to Complete | Notes                        |\n|----------|---------------------------|------------------------------|\n| requests | 987 ms or ~1013 req/s     | ThreadPoolExecutor. HTTP/1.1 |\n| httpx    | 720 ms or ~1389 req/s     | Asyncio. HTTP/2              |\n| niquests | 340 ms or ~2941 req/s     | Asyncio. HTTP/2              |\n\n**Simplified APIs**\n\n| Client        | Average Delay to Complete | Notes                        |\n|---------------|---------------------------|------------------------------|\n| requests core | 643 ms or ~1555 req/s     | ThreadPoolExecutor. HTTP/1.1 |\n| httpx core    | 490 ms or ~2000 req/s     | Asyncio. HTTP/2              |\n| aiohttp       | 210 ms or ~4762 req/s     | Asyncio. HTTP/1.1            |\n| niquests core | 160 ms or ~6200 req/s     | Asyncio. HTTP/2              |\n\nDid you give up on HTTP/2 due to performance concerns? Think again! Do you realize that you can get 3 times faster with the same CPU if you ever switched to Niquests from Requests?\nMultiplexing and response lazyness open up a wide range of possibilities! Want to learn more about the tests? scripts? reasoning?\n\nTake a deeper look at https://github.com/Ousret/niquests-stats\n\u003c/details\u003e\n\n```python\n\u003e\u003e\u003e import niquests\n\u003e\u003e\u003e s = niquests.Session(resolver=\"doh+google://\", multiplexed=True)\n\u003e\u003e\u003e r = s.get('https://one.one.one.one')\n\u003e\u003e\u003e r\n\u003cResponsePromise HTTP/3\u003e\n\u003e\u003e\u003e r.status_code\n200\n\u003e\u003e\u003e r.headers['content-type']\n'application/json; charset=utf-8'\n\u003e\u003e\u003e r.oheaders.content_type.charset\n'utf-8'\n\u003e\u003e\u003e r.encoding\n'utf-8'\n\u003e\u003e\u003e r.text\n'{\"authenticated\": true, ...'\n\u003e\u003e\u003e r.json()\n{'authenticated': True, ...}\n\u003e\u003e\u003e r\n\u003cResponse HTTP/3 [200]\u003e\n\u003e\u003e\u003e r.ocsp_verified\nTrue\n\u003e\u003e\u003e r.conn_info.established_latency\ndatetime.timedelta(microseconds=38)\n```\nor using async/await!\n```python\nimport niquests\nimport asyncio\n\nasync def main() -\u003e None:\n    async with niquests.AsyncSession(resolver=\"doh+google://\") as s:\n        r = await s.get('https://one.one.one.one', stream=True)\n        print(r)  # Output: \u003cResponse HTTP/3 [200]\u003e\n        payload = await r.text  # we await text because we set `stream=True`!\n        print(payload)  # Output: \u003chtml\u003e...\n        # or... without stream=True\n        r = await s.get('https://one.one.one.one')\n        print(r)  # Output: \u003cResponse HTTP/3 [200]\u003e\n        payload = r.text  # we don't need to away anything, it's already loaded!\n        print(payload)  # Output: \u003chtml\u003e...\n\nasyncio.run(main())\n```\n\nNiquests allows you to send HTTP requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your `PUT` \u0026 `POST` data — just use the `json` method!\n\n[![Downloads](https://img.shields.io/pypi/dm/niquests.svg)](https://pypistats.org/packages/niquests)\n[![Supported Versions](https://img.shields.io/pypi/pyversions/niquests.svg)](https://pypi.org/project/niquests)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9950/badge)](https://www.bestpractices.dev/projects/9950)\n\nThis project does not require any compilation toolchain. The HTTP/3 support is not enforced and installed if your platform can support it natively _(e.g. pre-built wheel available)_.\n\n## ✨ Installing Niquests and Supported Versions\n\nNiquests is available on PyPI:\n\n```console\n$ python -m pip install niquests\n```\n\nNiquests officially supports Python or PyPy 3.7+.\n\n## 🚀 Supported Features \u0026 Best–Practices\n\nNiquests is ready for the demands of building scalable, robust and reliable HTTP–speaking applications.\n\n- DNS over HTTPS, DNS over QUIC, DNS over TLS, and DNS over UDP\n- Automatic Content Decompression and Decoding\n- OS truststore by default, no more certifi!\n- OCSP Certificate Revocation Verification\n- Advanced connection timings inspection\n- In-memory certificates (CAs, and mTLS)\n- Browser-style TLS/SSL Verification\n- Sessions with Cookie Persistence\n- Keep-Alive \u0026 Connection Pooling\n- International Domains and URLs\n- Automatic honoring of `.netrc`\n- Basic \u0026 Digest Authentication\n- Familiar `dict`–like Cookies\n- Network settings fine-tuning\n- HTTP/2 with prior knowledge\n- Object-oriented headers\n- Multi-part File Uploads\n- Post-Quantum Security\n- Chunked HTTP Requests\n- Fully type-annotated!\n- SOCKS Proxy Support\n- Connection Timeouts\n- Streaming Downloads\n- HTTP/2 by default\n- HTTP/3 over QUIC\n- Early Responses\n- Happy Eyeballs\n- Multiplexed!\n- Thread-safe!\n- WebSocket!\n- Trailers!\n- DNSSEC!\n- Async!\n- SSE!\n\nNeed something more? Create an issue, we listen.\n\n## 📝 Why did we pursue this?\n\nFor 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.\n\nWe don't have to reinvent the wheel all over again, HTTP client **Requests** is well established and\nreally pleasant in its usage. We believe that **Requests** has the most inclusive and developer friendly interfaces.\nWe intend to keep it that way. As long as we can, long live Niquests!\n\nHow about a nice refresher with a mere `CTRL+H` _import requests_ **to** _import niquests as requests_ ?\n\n## 💼 For Enterprise\n\nProfessional support for Niquests is available as part of the [Tidelift\nSubscription](https://tidelift.com/subscription/pkg/pypi-niquests?utm_source=pypi-niquests\u0026utm_medium=readme). Tidelift gives software development teams a single source for\npurchasing and maintaining their software, with professional grade assurances\nfrom the experts who know it best, while seamlessly integrating with existing\ntools.\n\nYou may also be interested in unlocking specific advantages _(like access to a private issue tracker)_ by looking at our [GitHub sponsor tiers](https://github.com/sponsors/Ousret).\n\n---\n\nNiquests is a highly improved HTTP client that is based (forked) on Requests. The previous project original author is Kenneth Reitz and actually left the maintenance of Requests years ago.\n\n[^1]: aiohttp was conceived solely for an asynchronous context.\n[^2]: requests has no support for asynchronous request.\n[^3]: while the HTTP/2 connection object can handle concurrent requests, you cannot leverage its true potential.\n[^4]: loading client certificate without file can't be done.\n[^5]: httpx officially claim to be thread safe but recent tests demonstrate otherwise as of february 2024. https://github.com/jawah/niquests/issues/83#issuecomment-1956065258 https://github.com/encode/httpx/issues/3072 https://github.com/encode/httpx/issues/3002 and only recently acknowledged the issue in https://github.com/encode/httpx/issues/3324 (one year after getting valid reports).\n[^6]: they do not expose anything to control network aspects such as IPv4/IPv6 toggles, and timings (e.g. DNS response time, established delay, TLS handshake delay, etc...) and such.\n[^7]: while advertised as possible, they refuse to make it the default due to performance issues. as of October 2024 an extra is required to enable it manually.\n[^8]: they don't support HTTP/3 at all.\n[^9]: you must use a custom DNS resolver so that it can preemptively connect using HTTP/3 over QUIC when remote is compatible.\n[^10]: performance measured when leveraging a multiplexed connection with or without uses of any form of concurrency as of October 2024. The research compared `httpx`, `requests`, `aiohttp` against `niquests`. See https://github.com/Ousret/niquests-stats\n[^11]: enabled when using a custom DNS resolver.\n[^12]: available only when using HTTP/3 over QUIC and that the remote server support also the same post-quantum key-exchange algorithm. Also, the `qh3` installed version must be \u003e= 1.1.\n[^13]: most servers out there are not ready for this feature, but Niquests is already compliant and future-proof! [Caddy](https://github.com/caddyserver/caddy/releases/tag/v2.9.0) server and [HAProxy](https://github.com/haproxy/haproxy) support this!\n[^14]: they don't offer any built-in to speak with a WebSocket server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjawah%2Fniquests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjawah%2Fniquests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjawah%2Fniquests/lists"}