Main Interface¶
All of Request’s functionality can be accessed by these 6 methods. They all return a Response object.
- requests.head(url, **kwargs)¶
Sends a HEAD request. Returns Response object.
Parameters: - url – URL for the new Request object.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- headers – (optional) Dictionary of HTTP Headers to sent with the Request.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to False to disable redirect following.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.get(url, **kwargs)¶
Sends a GET request. Returns Response object.
Parameters: - url – URL for the new Request object.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- headers – (optional) Dictionary of HTTP Headers to send with the Request.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to False to disable redirect following.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.post(url, data='', **kwargs)¶
Sends a POST request. Returns Response object.
Parameters: - url – URL for the new Request object.
- data – (optional) Dictionary or bytes to send in the body of the Request.
- headers – (optional) Dictionary of HTTP Headers to sent with the Request.
- files – (optional) Dictionary of ‘filename’: file-like-objects for multipart encoding upload.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to True if redirect following is allowed.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.put(url, data='', **kwargs)¶
Sends a PUT request. Returns Response object.
Parameters: - url – URL for the new Request object.
- data – (optional) Dictionary or bytes to send in the body of the Request.
- headers – (optional) Dictionary of HTTP Headers to sent with the Request.
- files – (optional) Dictionary of ‘filename’: file-like-objects for multipart encoding upload.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to True if redirect following is allowed.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.patch(url, data='', **kwargs)¶
Sends a PATCH request. Returns Response object.
Parameters: - url – URL for the new Request object.
- data – (optional) Dictionary or bytes to send in the body of the Request.
- headers – (optional) Dictionary of HTTP Headers to sent with the Request.
- files – (optional) Dictionary of ‘filename’: file-like-objects for multipart encoding upload.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to True if redirect following is allowed.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.delete(url, **kwargs)¶
Sends a DELETE request. Returns Response object.
Parameters: - url – URL for the new Request object.
- params – (optional) Dictionary of parameters, or bytes, to be sent in the query string for the Request.
- headers – (optional) Dictionary of HTTP Headers to sent with the Request.
- cookies – (optional) Dict or CookieJar object to send with the Request.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to True if redirect following is allowed.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- requests.request(method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=False, proxies=None, hooks=None)¶
Constructs and sends a Request. Returns Response object.
Parameters: - method – method for the new Request object.
- url – URL for the new Request object.
- params – (optional) Dictionary or bytes to be sent in the query string for the Request.
- data – (optional) Dictionary or bytes 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 ‘filename’: file-like-objects for multipart encoding upload.
- auth – (optional) AuthObject to enable Basic HTTP Auth.
- timeout – (optional) Float describing the timeout of the request.
- allow_redirects – (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.
- proxies – (optional) Dictionary mapping protocol to the URL of the proxy.
- class requests.models.Response¶
The core Response object. All Request objects contain a response attribute, which is an instance of this class.
A dictionary of Cookies the server sent back.
- headers = None¶
Case-insensitive Dictionary of Response Headers. For example, headers['content-encoding'] will return the value of a 'Content-Encoding' response header.
- history = None¶
A list of Response objects from the history of the Request. Any redirect responses will end up here.
- ok = None¶
True if no error occured.
- request = None¶
The Request that created the Response.
- status_code = None¶
Integer Code of responded HTTP Status.
- url = None¶
Final URL location of Response.