Skip to main content

Anyquests

PyPI - Version PyPI - Python Version PyPI - License

Anyquests is a transparent wrapper around either requests or niquests which doesn't install either automatically.

Motivation

Niquests is a fork of requests made to address important flaws and support modern web features. However, to do this niquests depends on urllib3.future, which takes a dramatic approach to backwards compatibility by shadowing the original urllib3 if it is present. While this can be disabled during installation, a package including urllib3.future as a dependency (even transitive) cannot control this behavior. The potential of silently breaking users' installations can discourage them from depending on niquests. This package is meant to address this issue.

Rather than depending on one or the other, package authors can depend on anyquests and let the end user decide which library to install. Anyquests will pick whichever is available, prioritizing niquests.

I am an end user, which one to choose?

If you don't have any personal preference yet, choose niquests. niquests is a fork of requests which supports newer features such as HTTP/3 over QUIC. Be aware, however, that by default installing niquests will shadow urllib3 with a different, improved implementation. If this is a concern for you, see https://niquests.readthedocs.io/en/latest/community/faq.html#cohabitation for instructions on how to disable that. See also https://niquests.readthedocs.io/en/latest/community/faq.html#what-is-urllib3-future for an explanation of why niquests does that.

Usage

Add anyquests to the dependencies in your pyproject.toml, for example by running:

uv add anyquests

Then just import the library with:

import anyquests
# or
import anyquests as requests

The imported library will be the same as the result of either import niquests or import requests. If none are availabe, an ImportError will be raised with a helpful message instructing the user to install one or the other.

If you want to guarantee that your package will run out of the box even if the user doesn't have either requests or niquests installed, you can also add an explicit dependency on requests. anyquests will still opportunistically switch to niquests when available.

Note that this package does not impose any restrictions on the versions of either requests or niquests.

Typing

By default a type checker cannot know the members of anyquests or their types. This can be addressed with separate type stubs, but this would create tight coupling to specific versions of requests and niquests. Instead, since niquests promises to maintain full backwards compatibility with requests, the recommended solution is to:

  1. Include anyquests and requests as dependencies in your pyproject.toml.

  2. Include the following among your imports:

    from typing import TYPE_CHECKING
    
    import anyquests
    if TYPE_CHECKING:
        import requests as anyquests
    

    Alternatively, if you prefer using the name requests, include:

    from typing import TYPE_CHECKING
    
    import anyquests as requests
    if TYPE_CHECKING:
        import requests
    

Implementation

This package consists of just 25 lines of code, including empty lines and a multiline error message. It attempts to import niquests, then in case of failure, attempts to import requests, then in case of another failure raises an ImportError with an explanation and instructions. If an import succeeds, the anyquests module is fully substituted for the imported module, which maintains maximum compatibility and ensures no overhead.

If you believe you found an issue, or have an idea on how to improve this package, feel free to open an issue.

License

To match the licenses of the original requests and niquests, this package is licensed under the Apache License, Version 2.0.

© 2026 abel1502

Metadata

Release files for anyquests 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anyquests 1.0.1
File Size Uploaded Provenance Actions
anyquests-1.0.1.tar.gz 7.1 kB Without provenance Details for anyquests-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anyquests 1.0.1
File Interpreter ABI Platform Actions
anyquests-1.0.1-py3-none-any.whl Python 3 none any Details for anyquests-1.0.1-py3-none-any.whl

Total release size: 15.1 kB

Release files / anyquests-1.0.1.tar.gz

Download URL anyquests-1.0.1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
953fccf1b97a5f9b6eb9b2ba18ec057b3b0aa975b1c58c18aaa01afc41660987
BLAKE2b-256 checksum
How to use checksums
2ecf6879b70a541562998b91189ee200b58e9eb07766564e7d7a2aecd9b2b7a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / anyquests-1.0.1-py3-none-any.whl

Download URL anyquests-1.0.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebf7995e2e2c0826467ebd46b5bcc3e9232621e927e03ba216acfbfe00cd3e6a
BLAKE2b-256 checksum
How to use checksums
ac1303459c73085e39929bcefd055570eda746083307f58e5a229120c42eeda3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for anyquests 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page