Drop-in wrapper around the Python Requests library that provides extra features.
Project description
Drop-in wrapper around the Requests library that provides these extra features:
For resiliency:
Retry by default (3 times in total),
Timeout by default (10 seconds),
Exception on 4xx and 5xx responses by default (automatic raise_for_status()),
For performance:
Support for Brotli enabled by default,
How to use?
Replace requests with requests-extra in your dependencies file
Install requests-extra package
Replace requests. with requests_extra. in your code.
That’s it!
Example:
from requests_extra.api import get get('https://httpbin.org/headers')
TODO
Tests.
And more features:
Single line logging of requests and/or responses, with default secrets redaction,
HTTP/2 support (by switching to encode/httpx as a backend),
Rate limiting support, including respecting the appropriate HTTP headers,
Support for RFC-2782 style DNS SRV entries (for Consul) - see pstiasny/requests-srv,
Service-to-service authentication on GCP - see adrianchifor/requests-gcp,
Built-in support for caching responses? - maybe with reclosedev/requests-cache or bionikspoon/cache_requests
Contributing
ALL kinds of issues & PRs are very welcome! There are no formal rules of contributing yet, please use common sense. ;)
Credits
Of course big thanks to all the authors of the wrapped library, Requests!
The code for timeouts and raise_for_status() is copied from the better-requests/better-requests library. Thank you!
Some concepts from the CarlosAMolina/requests_custom library are used too. Thank you!
License
Like the wrapped Requests, and the libraries we reused, this library uses the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for requests_extra-1.0.0b3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef7bd5827fb75682d84c5f6fd8325849ac6e187525add613a19d2527b95e7b6 |
|
MD5 | a9d28d51d4ee862fefbe8a29fd746490 |
|
BLAKE2b-256 | 576b56fe41de85bffce59d0cbe04aaf686fd05c64a04b33f04f5c0057e607f21 |