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, orDELETE. - 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-tuplecan 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 andcustom_headersa dict-like object containing additional headers to add for the file. - auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.
- timeout (float or tuple): (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 (bool): (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
requesttakes. Ifallow_redirectsis not provided, it will be set toFalse(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
requesttakes.
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
requesttakes.
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
requesttakes.
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
requesttakes.
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
requesttakes.
Returns
Request object