# Requests — card for AI agents

Elegant Python HTTP library for making web requests.

Category: HTTP clients and networking · PyPI package `requests` · latest version 2.34.2 (checked 2026-11-01)
Install: `pip install requests`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (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.

## What it is
- Requests is an HTTP library for Python. The README calls it "a simple, yet elegant, HTTP library". The docs use the tagline "HTTP for Humans™" and say it is "built for human beings". The GitHub repository was created on 2011-02-13 and is Apache-2.0 licensed.
- You call a function such as `requests.get()` with a URL and options like `auth=('user', 'pass')`. The returned object exposes `status_code`, `headers`, `encoding`, `text` and `json()`. The README says there is no need to manually add query strings to your URLs or to form-encode `PUT` and `POST` data. The docs say keep-alive and connection pooling are handled by urllib3.
- It installs from PyPI with `python -m pip install requests`. The docs go past single calls into Session objects, prepared requests, transport adapters and event hooks. They also list companion packages such as CacheControl, Requests-Toolbelt, Requests-OAuthlib and Betamax.

## Caveats
- Official support is Python 3.10+: The docs say Requests officially supports Python 3.10+. They add that it "runs great on PyPy".
- `Request.headers.update()` callers may need typing changes: Release 2.34.2 moved the `headers` input type back to `Mapping`. The release notes say users calling `Request.headers.update()` may need to narrow typing in their code.

## Numbers (AgentGid data)
- Gid Score: 88.0 (#17 of all tools, 2 of 126 in its category)
- Used in 425 public projects set up for AI coding agents (6.8%)
- Downloads last week: 349,971,624 (as of 2026-11-24), +11.7% over 4 weeks
- GitHub stars: 54,746 (as of 2026-11-24)
- Last push: 2026-11-02

## Often used with
python-dotenv 56.9%, Pydantic 44.0%, Uvicorn 40.5%, NumPy 38.1%, FastAPI 36.2%, PyYAML 36.0%

## Checked alternatives (same job)
- httpx: https://agentgid.com/tools/httpx/agent.md
- aiohttp: https://agentgid.com/tools/aiohttp/agent.md
- urllib3: https://agentgid.com/tools/urllib3/agent.md
- websocket-client: https://agentgid.com/tools/websocket-client/agent.md
- h2: https://agentgid.com/tools/h2/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/requests-py/
- Repository: https://github.com/psf/requests
- Source: https://github.com/psf/requests#readme
- Source: https://github.com/psf/requests
- Source: https://github.com/psf/requests/releases
- Source: https://requests.readthedocs.io/en/latest/


## Requests: talk to web services from Python

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.

### Where to use 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.

### How to start
- Install requests into your project's Python environment (Python 3.10 or newer).

```
python -m pip install requests
```

- 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, ...}
```

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

### License
Free to use, also in paid and closed-source products, under the Apache-2.0 license. If you ship it inside your app, keep its license text with it. You do not have to credit it on screen.

### Good to know
- It needs Python 3.10 or newer; version 2.33.0 dropped Python 3.9.
- By default a request never gives up waiting. Set a timeout on every call, or a stuck service can freeze your script.
- Each call waits for its answer before the program goes on. For many calls at the same time, the docs point to other tools such as httpx.
- It checks the security certificate of every https site, like a browser. Turning that check off is only for local testing.
- The project is maintained under the Python Software Foundation; the last release, 2.34.2, came out on 2026-05-14.

Checked 2026-11-10 against: https://requests.readthedocs.io/en/latest/, https://requests.readthedocs.io/en/latest/user/install/, https://requests.readthedocs.io/en/latest/user/quickstart/, https://requests.readthedocs.io/en/latest/user/advanced/, https://requests.readthedocs.io/en/latest/user/authentication/, https://requests.readthedocs.io/en/latest/community/faq/, https://github.com/psf/requests/blob/main/README.md, https://github.com/psf/requests/blob/main/LICENSE, https://github.com/psf/requests/blob/main/HISTORY.md, https://github.com/psf/requests/blob/main/pyproject.toml, https://pypi.org/pypi/requests/json

### Mistakes to avoid
- Don't: requests.get(url) with no timeout → Do: 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.)
- Don't: requests.post(url, data=json.dumps(payload)) → Do: 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.)
- Don't: data = r.json() right after the call, treating it as success → Do: 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.)
- Don't: verify=False to get past a certificate error → Do: 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.)
- Don't: pip install types-requests next to requests 2.34+, or a custom HTTPAdapter overriding _get_connection → Do: 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].

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
