API reference
Requests API reference
Requests HTTP for humans
- Identifiers
- 12
- With full guides
- 10
- Types
- 3
Topics covered
- GET & POST
- Query params
- Headers
- JSON
- Sessions
- Auth
- Timeouts
- Error handling
Class
| Name | What it does |
|---|---|
Session | A Requests Session groups HTTP calls while persisting selected settings and cookies. It also provides connection pooling and can be used as a context manager for automatic cleanup. |
Response | |
Request | Request is a user-created description of an HTTP request. Prepare it to obtain a PreparedRequest that can be sent to a server. |
Function
| Name | What it does |
|---|---|
requests.get | Sends an HTTP GET request and returns a requests.Response. Query-string data goes in params; other request options are supplied as keyword arguments. |
requests.post | Sends an HTTP POST request and returns a Response. Supply the body with data or with a JSON-serializable value via json, while other request options are passed as keyword arguments. |
requests.put | Sends an HTTP PUT request and returns the resulting Response. The request body may be supplied with data or json, while other request options are passed as keyword arguments. |
requests.delete | Sends an HTTP DELETE request to a URL and returns the resulting Response object. Optional keyword arguments use the same request configuration supported by requests.request. |
json | Response.json() decodes a response body as JSON and returns the corresponding Python object, such as a dictionary or list. It raises an exception when decoding fails. |
raise_for_status | Response.raise_for_status() raises HTTPError for an unsuccessful HTTP response and otherwise returns None. Use it after a request to enforce response-status validation before handling the result. |
Const
| Name | What it does |
|---|---|
headers | |
status_code | Response.status_code is the integer HTTP status returned by a server, such as 200 or 404. Use it for exact status checks, optionally comparing it with a named value from requests.codes. |
params | params supplies query-string data to Requests calls. Provide a dictionary, tuple list, or bytes; Requests encodes it into the URL and returns a Response. |
Search across every package and filter by type in your dashboard.
Start learning