requests api this module implements the requests api c 2012 by kenneth reitz license apache2 see license for more details constructs and sends a class request request param method method for the new class request object get options head post put patch or delete param url url for the new class request object param params optional dictionary list of tuples or bytes to send in the query string for the class request param data optional dictionary list of tuples bytes or filelike object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param headers optional dictionary of http headers to send with the class request param cookies optional dict or cookiejar object to send with the class request param files optional dictionary of name filelikeobjects or name filetuple for multipart encoding upload filetuple can be a 2tuple filename fileobj 3tuple filename fileobj contenttype or a 4tuple filename fileobj contenttype customheaders where contenttype is a string defining the content type of the given file and customheaders a dictlike object containing additional headers to add for the file param auth optional auth tuple to enable basicdigestcustom http auth param timeout optional how many seconds to wait for the server to send data before giving up as a float or a ref connect timeout read timeout timeouts tuple type timeout float or tuple param allowredirects optional boolean enabledisable getoptionspostputpatchdeletehead redirection defaults to true type allowredirects bool param proxies optional dictionary mapping protocol to the url of the proxy param 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 param stream optional if false the response content will be immediately downloaded param cert optional if string path to ssl client cert file pem if tuple cert key pair return class response response object rtype requests response usage import requests req requests request get https httpbin orgget req response 200 by using the with statement we are sure the session is closed thus we avoid leaving sockets open which can trigger a resourcewarning in some cases and look like a memory leak in others return requestget url paramsparams kwargs def optionsurl kwargs rsends an options request param url url for the new class request object param kwargs optional arguments that request takes return class response response object rtype requests response kwargs setdefaultallowredirects false return requesthead url kwargs def posturl datanone jsonnone kwargs rsends a post request param url url for the new class request object param data optional dictionary list of tuples bytes or filelike object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param kwargs optional arguments that request takes return class response response object rtype requests response return requestput url datadata kwargs def patchurl datanone kwargs rsends a patch request param url url for the new class request object param data optional dictionary list of tuples bytes or filelike object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param kwargs optional arguments that request takes return class response response object rtype requests response return requestdelete url kwargs constructs and sends a class request request param method method for the new class request object get options head post put patch or delete param url url for the new class request object param params optional dictionary list of tuples or bytes to send in the query string for the class request param data optional dictionary list of tuples bytes or file like object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param headers optional dictionary of http headers to send with the class request param cookies optional dict or cookiejar object to send with the class request param 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 param auth optional auth tuple to enable basic digest custom http auth param timeout optional how many seconds to wait for the server to send data before giving up as a float or a ref connect timeout read timeout timeouts tuple type timeout float or tuple param allow_redirects optional boolean enable disable get options post put patch delete head redirection defaults to true type allow_redirects bool param proxies optional dictionary mapping protocol to the url of the proxy param 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 param stream optional if false the response content will be immediately downloaded param cert optional if string path to ssl client cert file pem if tuple cert key pair return class response response object rtype requests response usage import requests req requests request get https httpbin org get req response 200 by using the with statement we are sure the session is closed thus we avoid leaving sockets open which can trigger a resourcewarning in some cases and look like a memory leak in others sends a get request param url url for the new class request object param params optional dictionary list of tuples or bytes to send in the query string for the class request param kwargs optional arguments that request takes return class response response object rtype requests response sends an options request param url url for the new class request object param kwargs optional arguments that request takes return class response response object rtype requests response sends a head request param url url for the new class request object param kwargs optional arguments that request takes if allow_redirects is not provided it will be set to false as opposed to the default meth request behavior return class response response object rtype requests response sends a post request param url url for the new class request object param data optional dictionary list of tuples bytes or file like object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param kwargs optional arguments that request takes return class response response object rtype requests response sends a put request param url url for the new class request object param data optional dictionary list of tuples bytes or file like object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param kwargs optional arguments that request takes return class response response object rtype requests response sends a patch request param url url for the new class request object param data optional dictionary list of tuples bytes or file like object to send in the body of the class request param json optional a json serializable python object to send in the body of the class request param kwargs optional arguments that request takes return class response response object rtype requests response sends a delete request param url url for the new class request object param kwargs optional arguments that request takes return class response response object rtype requests response
from . import sessions


def request(method, url, **kwargs):
    

    
    
    
    with sessions.Session() as session:
        return session.request(method=method, url=url, **kwargs)


def get(url, params=None, **kwargs):
    r

    return request("get", url, params=params, **kwargs)


def options(url, **kwargs):
    r

    return request("options", url, **kwargs)


def head(url, **kwargs):
    r

    kwargs.setdefault("allow_redirects", False)
    return request("head", url, **kwargs)


def post(url, data=None, json=None, **kwargs):
    r

    return request("post", url, data=data, json=json, **kwargs)


def put(url, data=None, **kwargs):
    r

    return request("put", url, data=data, **kwargs)


def patch(url, data=None, **kwargs):
    r

    return request("patch", url, data=data, **kwargs)


def delete(url, **kwargs):
    r

    return request("delete", url, **kwargs)