Skip to content

botcity.plugins.http.BotHttpPlugin

__init__(url, params=None)

BotHttpPlugin

Parameters:

Name Type Description Default
url str

The URL to send requests to.

required
params (dict, Optional)

Additional parameters to send with your requests. Defaults to None.

None

Attributes:

Name Type Description
url str

The URL to send requests to.

params (dict, Optional)

Additional parameters to send with your requests. Defaults to None.

add_param(key, value)

Adds a parameter to the parameters dictionary.

Parameters:

Name Type Description Default
key str

Header key.

required
value object

Header value.

required

Returns:

Type Description
BotHttpPlugin

self (allows Method Chaining)

get()

Sends an http get request to the URL defined in this class.

Returns:

Type Description
Response

The content of the server response in its raw format.

get_as_file(file_name)

Performs an http get request, then saves its response as a file.

Parameters:

Name Type Description Default
file_name str

The name of the file.

required

Returns:

Type Description
str

(str) The resulting file_name.

get_as_json()

Sends an http get request to the URL defined in this class, and returns the JSON formatted answer. This method is equivalent to get().json().

Returns:

Type Description
Dict

The content of the server response in json format

get_bytes()

Sends an http get request to the URL defined in this class, and returns the answer as bytes. This method is equivalent to get().content

Returns:

Type Description
bytes

The content of the server response in bytes

post()

Sends an http post request to the URL defined in this class.

Returns:

Type Description
Response

The content of the server response in its raw format.

post_as_json()

Sends an http post request to the URL defined in this class, and returns the JSON formatted answer. This method is equivalent to post().json().

Returns:

Type Description
Dict

The content of the server response in json format.