Skip to content

botcity.plugins.http.plugin.BotHttpPlugin

__init__(self, url, params=None) special

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(self, 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(self)

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(self, 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(self)

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(self)

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(self)

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(self)

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.