Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Requests

Talk to web services from Python.

HTTP clients and networkingPYPI

GitHub

1. License

“each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.”

Free for commercial and closed-source use under Apache-2.0.

github.com/psf/requests/blob/main/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What Requests does

Requests is a free Python library that lets your program fetch web pages and talk to online services in a few lines. Your app can ask a weather or payment service for data, send forms and files, and stay logged in across several requests. It waits for each answer before going on, so very busy apps that must do many things at once use other libraries.

What people build with it

Ask an online service for data

A script or app asks a weather, maps or shop service for data and reads the answer as plain Python values.

Send data with your key

Your app saves a note, a lead or an order in another service and sends your secret key in a header with it.

Upload files to a service

Send a report, a photo or a CSV export to a service the way a web form would, with the file name and type.

Retry when a service hiccups

When a busy service answers "try again later", your script waits a little and tries again instead of failing at once.

Download big files in pieces

Save a large export or video to disk piece by piece, so the whole file never has to fit in memory.

Stay logged in across requests

Log in to a site or service once and keep its cookies and headers for every next request in the same script.

Requests popularity

88 / 100
Gid Score, #17 overall
35M
downloads a week, pypi
54.7K
GitHub stars
425
agent projects use it
Requests: downloads per weekPyPI, requests 348,820,878
Requests: GitHub starspsf/requests 54,746

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Requests is used

  • Requests is a dependency in 425 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (26.2% of the 1,623 Python ones), #2 of 126 in http clients and networking.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 3,788; those are left out of every share on this page.
  • The most used alternative in our scan is httpx (280 projects).
  • Projects that use it most often also use python-dotenv (56.9%), Pydantic (44.0%), Uvicorn (40.5%).
  • It is more common in projects set up for OpenClaw (12.9%) than for OpenCode (3.2%).

By coding agent

207 projects, 6.8%
206 projects, 6.3%
153 projects, 6.3%
43 projects, 12.9%
24 projects, 5.1%
20 projects, 7.2%
17 projects, 3.6%
11 projects, 3.2%

Often used with

In 56.9% of its projects
In 44.0% of its projects
In 40.5% of its projects
In 38.1% of its projects
In 36.2% of its projects
In 36.0% of its projects
In 29.4% of its projects
In 26.1% of its projects

Requests in practice

Strengths

No hand-built query strings or form bodies

The README says there is no need to manually add query strings to URLs or to form-encode <code>PUT</code> and <code>POST</code> data. For JSON it adds: "nowadays, just use the <code>json</code> method!"

Keep-alive and pooling come from urllib3

The docs say keep-alive and HTTP connection pooling are "100% automatic" and credit urllib3 for this.

Docs cover Transport Adapters and blocking behavior

The Advanced Usage section has chapters titled "Transport Adapters" and "Blocking Or Non-Blocking?". If your project needs concurrent requests, read the second one before you commit. The Community Guide also lists a Requests-Threads package.

Auth docs go past Basic

The docs have separate pages for Basic, Digest, OAuth 1, and OAuth 2 and OpenID Connect authentication. A further page covers writing new forms of authentication.

Watch out for

Official support is Python 3.10+

The docs say Requests officially supports Python 3.10+. They add that it "runs great on PyPy".

<code>Request.headers.update()</code> callers may need typing changes

Release 2.34.2 moved the <code>headers</code> input type back to <code>Mapping</code>. The release notes say users calling <code>Request.headers.update()</code> may need to narrow typing in their code.

Basic auth and reading the response

>>> import requests
>>> r = requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass'))
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.encoding
'utf-8'
>>> r.text
'{"authenticated": true, ...'
>>> r.json()
{'authenticated': True, ...}

More about Requests

Funding
  • Own page: https://www.python.org/psf/sponsorship/

See all

Head to head
Packages around it
  • python-dotenv: Loads .env config
  • solders: Solana Python types
  • pydantic: Data validation
  • numpy: Numeric arrays
  • solana: Solana Python client
  • uvicorn: ASGI server
More in HTTP clients and networking

Alternatives

Requests This page

Apache-2.0Gid 8835M/wk

httpx

Pick httpx when your Python app needs async calls or many requests at once with an API close to requests.

BSDGid 78198M/wk

aiohttp

Pick aiohttp when you build an asyncio app that also serves web pages or WebSockets itself.

Apache-2.0 AND MITGid 81134M/wk

urllib3

Pick urllib3 when you want the lower-level connection pooling library that requests itself is built on.

MITGid 75376M/wk

websocket-client

WebSocket client library for Python with low-level API options.

Apache-2.0Gid 6941.6M/wk

h2

Pure Python HTTP/2 protocol implementation for building HTTP/2 clients.

MITGid 6448.2M/wk

Compare Requests with another tool

Get started

Tell your AI assistant

“Use the Python library requests (pin requests==2.34.2, Python 3.10+) to call the service; pass timeout= on every call, call raise_for_status() before reading r.json(), and read the token from an environment variable.”

  1. Install requests into your project's Python environment (Python 3.10 or newer).

    python -m pip install requests

    From github.com/psf/requests/blob/main/README.md

  2. Make a request and read the status, headers and body of the answer.

    >>> import requests
    >>> r = requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass'))
    >>> r.status_code
    200
    >>> r.json()
    {'authenticated': True, ...}
    

    From github.com/psf/requests/blob/main/README.md

  3. Always pass a timeout; without it a request can wait forever.

    From requests.readthedocs.io/en/latest/user/quickstart/

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Requests
- Install with `python -m pip install requests`. The project officially supports Python 3.10+.
- Do not add query strings to URLs by hand or form-encode `PUT`/`POST` data yourself. The README says there is no need, and for JSON it says "nowadays, just use the `json` method!"
- For basic auth, pass `auth=('user', 'pass')` to the request call, as the README example does.
- Do not write your own keep-alive or connection pooling. The docs say both are "100% automatic, thanks to urllib3".
- Before handling cookies across requests by hand, read the docs' Session Objects section. The docs list "Sessions with Cookie Persistence" as a feature.
- If the code needs concurrent requests, read the docs' "Blocking Or Non-Blocking?" section first.

Mistakes to avoid

requests.get(url) with no timeout
requests.get(url, timeout=5) or timeout=(3.05, 27) for separate connect and read limits

Without a timeout a request can wait forever; in our run timeout=1 against a 3-second server raised ReadTimeout as expected.

requests.post(url, data=json.dumps(payload))
requests.post(url, json=payload)

data= with a string sends no Content-Type, so many services reject it; in our run data= gave Content-Type None, json= gave application/json.

data = r.json() right after the call, treating it as success
Call r.raise_for_status() (or check r.status_code) first, then r.json()

Error answers can carry a JSON body too, and r.json() decodes it without complaint.

verify=False to get past a certificate error
Keep verify=True and point verify= or REQUESTS_CA_BUNDLE at the right CA file; upgrade certifi

verify=False accepts any certificate and opens the app to man-in-the-middle attacks.

pip install types-requests next to requests 2.34+, or a custom HTTPAdapter overriding _get_connection
Drop types-requests (requests ships its own types since 2.34.0); override get_connection_with_tls_context in adapters

The typing stubs moved into the package in 2.34.0, and the adapter hook was renamed in 2.32.2.

Questions

Can I use it in a paid, closed-source app?

Yes. The Apache-2.0 license allows commercial use; keep the license text if you ship the library with your app.

Does it retry failed requests by itself?

No. You add retries with urllib3's Retry class mounted on a Session.

Does r.json() working mean the request succeeded?

No. A server can send an error with a JSON body; check r.raise_for_status() or the status code.

Can it do async calls?

Not with its default setup; every call blocks. The docs mention httpx and other projects for that.

Does it support SOCKS proxies?

Yes, after installing the extra requests[socks].