class telegram.request.RequestData(parameters=None)[source]#

Bases: object

Instances of this class collect the data needed for one request to the Bot API, including all parameters and files to be sent along with the request.

New in version 20.0.


How exactly instances of this will are created should be considered an implementation detail and not part of PTBs public API. Users should exclusively rely on the documented attributes, properties and methods.


Whether this object contains files to be uploaded via multipart/form-data.



property json_parameters[source]#

Gives the parameters as mapping of parameter name to the respective JSON encoded value.

property json_payload[source]#

The parameters as UTF-8 encoded JSON payload.

property multipart_data[source]#

Gives the files contained in this object as mapping of part name to encoded content.

property parameters[source]#

Gives the parameters as mapping of parameter name to the parameter value, which can be a single object of type int, float, str or bool or any (possibly nested) composition of lists, tuples and dictionaries, where each entry, key and value is of one of the mentioned types.

parametrized_url(url, encode_kwargs=None)[source]#

Shortcut for attaching the return value of url_encoded_parameters() to the url.


Encodes the parameters with urllib.parse.urlencode().


encode_kwargs (Dict[str, any], optional) – Additional keyword arguments to pass along to urllib.parse.urlencode().