Skip to content

API Actions

API Actions are actions to send HTTP requests

Actions Parameters

url – URL where the request will be sent

data (optional) - Content that will be send as request body, could be a string, a dictionary, list of tuples, bytes, or file-like object

headers (optional) - Dictionary of HTTP Headers to send with the Request

json (optional) - A dictionary as a JSON like object to be send as the body of hte request

params (optional) - Query strings that will be sent on request as dictionary, list of tuples or bytes

cookies (optional) - Dict or CookieJar object to send with the Request

auth_user (optional) - User to authenticate with the url

auth_pass (optional) - Password to authenticate with the url

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.

files = {'file': open('report.xls', 'rb')}

api.post('https://systemexample.com', files=files)

You can also send strings to be received as files:

files = {'file': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}

api.post('https://systemexample.com', files=files)

timeout (optional) - How many seconds to wait for the server to send data before giving up, as a float

allow_redirects (optional) – Could be set to True or False, to Enable/disable GET/POST/PUT/PATCH/DELETE redirection. (Defaults=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

Actions

api.get

Do a request using GET method

Parameters:

A complete list of all actions parameters could be found at this link

Return:

content - Returns the content of the response

encoding - Returns the encoding used to decode response.content

headers - Returns a dictionary of response headers

json - Returns a JSON object of the result, None if response not in JSON format

reason - Returns a text corresponding to the status code. For example, 'OK' for 200, 'Not Found' for 404

status_code - Returns the status code to indicate the response status

url - Returns the URL of the response after all redirections, if done

api.post

Do a request using POST method

Parameters:

A complete list of all actions parameters could be found at this link

Return:

content - Returns the content of the response

encoding - Returns the encoding used to decode response.content

headers - Returns a dictionary of response headers

json - Returns a JSON object of the result, None if response not in JSON format

reason - Returns a text corresponding to the status code. For example, 'OK' for 200, 'Not Found' for 404

status_code - Returns the status code to indicate the response status

url - Returns the URL of the response after all redirections, if done

api.put

Do a request using PUT method

Parameters:

A complete list of all actions parameters could be found at this link

Return:

content - Returns the content of the response

encoding - Returns the encoding used to decode response.content

headers - Returns a dictionary of response headers

json - Returns a JSON object of the result, None if response not in JSON format

reason - Returns a text corresponding to the status code. For example, 'OK' for 200, 'Not Found' for 404

status_code - Returns the status code to indicate the response status

url - Returns the URL of the response after all redirections, if done

api.delete

Do a request using DELETE method

Parameters:

A complete list of all actions parameters could be found at this link

Return:

content - Returns the content of the response

encoding - Returns the encoding used to decode response.content

headers - Returns a dictionary of response headers

json - Returns a JSON object of the result, None if response not in JSON format

reason - Returns a text corresponding to the status code. For example, 'OK' for 200, 'Not Found' for 404

status_code - Returns the status code to indicate the response status

url - Returns the URL of the response after all redirections, if done

api.patch

Do a request using PATCH method

Parameters:

A complete list of all actions parameters could be found at this link

Return:

content - Returns the content of the response

encoding - Returns the encoding used to decode response.content

headers - Returns a dictionary of response headers

json - Returns a JSON object of the result, None if response not in JSON format

reason - Returns a text corresponding to the status code. For example, 'OK' for 200, 'Not Found' for 404

status_code - Returns the status code to indicate the response status

url - Returns the URL of the response after all redirections, if done