Main interface


requests.request

requests.request(method, url, **kwargs)

Constructs and sends a Request.

Arguments

  • method: method for the new Request object: GET, OPTIONS, HEAD, POST, PUT, PATCH, or DELETE.
  • url: URL for the new Request object.
  • params: (optional) Dictionary, list of tuples or bytes to send in the query string for the Request.
  • data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.
  • json: (optional) A JSON serializable Python object to send in the body of the Request.
  • headers: (optional) Dictionary of HTTP Headers to send with the Request.
  • cookies: (optional) Dict or CookieJar object to send with the Request.
  • files: (optional) Dictionary of 'name': file-like-objects (or {'name': file-tuple}) for multipart encoding upload. file-tuple can be a 2-tuple ('filename', fileobj), 3-tuple ('filename', fileobj, 'content_type') or a 4-tuple ('filename', fileobj, 'content_type', custom_headers), where 'content_type' is a string defining the content type of the given file and custom_headers a dict-like object containing additional headers to add for the file.
  • auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
  • timeout: (optional) How many seconds to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
  • allow_redirects: (optional) Boolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to True.
  • proxies: (optional) Dictionary mapping protocol to the URL of the proxy.
  • verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True.
  • stream: (optional) if False, the response content will be immediately downloaded.
  • cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.

Returns

Request object


requests.head

requests.head(url, **kwargs)

Sends a HEAD request.

Arguments

  • url: URL for the new Request object.
  • **kwargs: Optional arguments that request takes. If allow_redirects is not provided, it will be set to False (as opposed to the default request behavior).

Returns

Request object


requests.get

requests.get(url, params=None, **kwargs)

Sends a GET request.

Arguments

  • url: URL for the new Request object.
  • params: (optional) Dictionary, list of tuples or bytes to send in the query string for the Request.
  • **kwargs: Optional arguments that request takes.

Returns

Request object


requests.post

requests.post(url, data=None, json=None, **kwargs)

Sends a POST request.

Arguments

  • url: URL for the new Request object.
  • data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.
  • json: (optional) A JSON serializable Python object to send in the body of the Request.
  • **kwargs: Optional arguments that request takes.

Returns

Request object


requests.put

requests.put(url, data=None, **kwargs)

Sends a PUT request.

Arguments

  • url: URL for the new Request object.
  • data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.
  • json: (optional) A JSON serializable Python object to send in the body of the Request.
  • **kwargs: Optional arguments that request takes.

Returns

Request object


requests.patch

requests.patch(url, data=None, **kwargs)

Sends a PATCH request.

Arguments

  • url: URL for the new Request object.
  • data: (optional) Dictionary, list of tuples, bytes, or file-like object to send in the body of the Request.
  • json: (optional) A JSON serializable Python object to send in the body of the Request.
  • **kwargs: Optional arguments that request takes.

Returns

Request object


requests.delete

requests.delete(url, **kwargs)

Sends a DELETE request.

Arguments

  • url: URL for the new Request object.
  • **kwargs: Optional arguments that request takes.

Returns

Request object