| 1 |
# Requests |
| 2 |
|
| 3 |
[](https://pypi.org/project/requests/) |
| 4 |
[](https://pypi.org/project/requests) |
| 5 |
[](https://pepy.tech/project/requests) |
| 6 |
[](https://github.com/psf/requests/graphs/contributors) |
| 7 |
[](https://requests.readthedocs.io) |
| 8 |
|
| 9 |
**Requests** is a simple, yet elegant, HTTP library. |
| 10 |
|
| 11 |
```python |
| 12 |
>>> import requests |
| 13 |
>>> r = requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass')) |
| 14 |
>>> r.status_code |
| 15 |
200 |
| 16 |
>>> r.headers['content-type'] |
| 17 |
'application/json; charset=utf8' |
| 18 |
>>> r.encoding |
| 19 |
'utf-8' |
| 20 |
>>> r.text |
| 21 |
'{"authenticated": true, ...' |
| 22 |
>>> r.json() |
| 23 |
{'authenticated': True, ...} |
| 24 |
``` |
| 25 |
|
| 26 |
Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your `PUT` & `POST` data — but nowadays, just use the `json` method! |
| 27 |
|
| 28 |
Requests is one of the most downloaded Python packages today, pulling in around `300M downloads / week` — according to GitHub, Requests is currently [depended upon](https://github.com/psf/requests/network/dependents?package_id=UGFja2FnZS01NzA4OTExNg%3D%3D) by `4,000,000+` repositories. |
| 29 |
|
| 30 |
## Installing Requests and Supported Versions |
| 31 |
|
| 32 |
Requests is available on PyPI: |
| 33 |
|
| 34 |
```console |
| 35 |
$ python -m pip install requests |
| 36 |
``` |
| 37 |
|
| 38 |
Requests officially supports Python 3.10+. |
| 39 |
|
| 40 |
## Supported Features & Best–Practices |
| 41 |
|
| 42 |
Requests is ready for the demands of building robust and reliable HTTP–speaking applications, for the needs of today. |
| 43 |
|
| 44 |
- Keep-Alive & Connection Pooling |
| 45 |
- International Domains and URLs |
| 46 |
- Sessions with Cookie Persistence |
| 47 |
- Browser-style TLS/SSL Verification |
| 48 |
- Basic & Digest Authentication |
| 49 |
- Familiar `dict`–like Cookies |
| 50 |
- Automatic Content Decompression and Decoding |
| 51 |
- Multi-part File Uploads |
| 52 |
- SOCKS Proxy Support |
| 53 |
- Connection Timeouts |
| 54 |
- Streaming Downloads |
| 55 |
- Automatic honoring of `.netrc` |
| 56 |
- Chunked HTTP Requests |
| 57 |
|
| 58 |
## Cloning the repository |
| 59 |
|
| 60 |
When cloning the Requests repository, you may need to add the `-c |
| 61 |
fetch.fsck.badTimezone=ignore` flag to avoid an error about a bad commit timestamp (see |
| 62 |
[this issue](https://github.com/psf/requests/issues/2690) for more background): |
| 63 |
|
| 64 |
```shell |
| 65 |
git clone -c fetch.fsck.badTimezone=ignore https://github.com/psf/requests.git |
| 66 |
``` |
| 67 |
|
| 68 |
You can also apply this setting to your global Git config: |
| 69 |
|
| 70 |
```shell |
| 71 |
git config --global fetch.fsck.badTimezone ignore |
| 72 |
``` |
| 73 |
|
| 74 |
--- |
| 75 |
|
| 76 |
[](https://kennethreitz.org) [](https://www.python.org/psf) |