Skip to main content

Drop-in wrapper around the Python Requests library that provides extra features.

Project description

status version release date linter tests

requests-extra

Drop-in replacement for the Requests library that wraps it to provide these ✨extra✨ features:

Improved resiliency 🤘

  • Retry by default (3 times in total) with backoff / respecting Retry-After,

  • Timeout by default (10 seconds),

  • Exception on 4xx and 5xx responses by default (automatic raise_for_status()),

Improved performance

  • Automatic HTTP keep-alive without explicitly using session,

  • Support for Brotli enabled by default,

When to use it?

This library is highly opinionated and uses a rather simplistic approach so it may or may not fit your project. For us it did help in the following use cases:

  • improving many small scripts - f.e. used for monitoring,

  • modernization of a big but simple and well-tested projects - f.e. old tests,

How to use?

  1. Replace requests with requests-extra in your dependencies file

  2. Replace requests. with requests_extra. in your code.

That’s it!

Example:

# instead of 'from requests import get'
from requests_extra import get

get('https://httpbin.org/headers')

For more examples please see the tests.

How to change the defaults?

See defaults.py.

To change some of them for all of your code do this:

import requests_extra.defaults

requests_extra.defaults.timeout = 1

You can also overwrite them for a single request in the usual way:

from requests_extra import get

get('https://httpbin.org', timeout=5)

TODO

More features:

Contributing

ALL kinds of issues & PRs are very welcome! There are no formal rules of contributing yet, please use common sense. ;)

Credits

Firstly big thanks to all the authors of the wrapped library, Requests!

Additionally thank you to the authors of reused code:

License

Like the wrapped Requests, and the libraries we reused, this library uses the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_extra-1.0.0b8.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

requests_extra-1.0.0b8-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file requests_extra-1.0.0b8.tar.gz.

File metadata

  • Download URL: requests_extra-1.0.0b8.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7

File hashes

Hashes for requests_extra-1.0.0b8.tar.gz
Algorithm Hash digest
SHA256 b60b45f74630c23c61bf93c2f883e954746a6ff78e10cac392d05e95b29cb699
MD5 4815ece9e8cdc03787408d8a6702e0d3
BLAKE2b-256 32e81094e474ae45bdc7fb4d23747de8bde2d847524f1425a23b9d41ae4315a8

See more details on using hashes here.

File details

Details for the file requests_extra-1.0.0b8-py3-none-any.whl.

File metadata

  • Download URL: requests_extra-1.0.0b8-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7

File hashes

Hashes for requests_extra-1.0.0b8-py3-none-any.whl
Algorithm Hash digest
SHA256 cf12240066901b68253db0f154300e9e53273aa5d02a95df2a7485fda4c1c8a3
MD5 89e3e99989397b5d4f4c6def294f071f
BLAKE2b-256 950e150943f28938af3d50cd4b6ffa6cf9d9904bdf475b0f6815d122a21b4824

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page