Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

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

NameWhat it does
SessionA 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.
ResponseClass
RequestRequest is a user-created description of an HTTP request. Prepare it to obtain a PreparedRequest that can be sent to a server.

Function

NameWhat it does
requests.getSends an HTTP GET request and returns a requests.Response. Query-string data goes in params; other request options are supplied as keyword arguments.
requests.postSends 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.putSends 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.deleteSends 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.
jsonResponse.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_statusResponse.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

NameWhat it does
headersConst
status_codeResponse.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.
paramsparams 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