oauth

  • Functions for interacting with the public Trackmania API

delete(token: OAuthToken, endpoint: str, params: dict = {}, body: dict = {}) dict | list[source]
  • sends a DELETE request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

  • body (dict) –

    • request body, if applicable

    • default: {} (empty)

Returns:

  • response body

Return type:

dict | list

get(token: OAuthToken, endpoint: str, params: dict = {}) dict | list[source]
  • sends a GET request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here else they will be duplicated

Returns:

  • response body

Return type:

dict | list

get_account_ids_from_names(token: OAuthToken, account_names: Iterable[str]) dict[source]
Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • account_names (Iterable[str]) –

    • account names

    • if a name is not found, it will be omitted from the results

Returns:

  • returned account IDs as values with given account names as keys

Return type:

dict

get_account_names_from_ids(token: OAuthToken, account_ids: Iterable[str]) dict[source]
Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • account_ids (Iterable[str]) –

    • account IDs (max 50)

    • if an ID is not found, it will be omitted from the results

Returns:

  • returned account names as values with given account IDs as keys

Return type:

dict

head(token: OAuthToken, endpoint: str, params: dict = {}) dict | list[source]
  • sends a HEAD request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

Returns:

  • response body

Return type:

dict | list

options(token: OAuthToken, endpoint: str, params: dict = {}, body: dict = {}) dict | list[source]
  • sends an OPTIONS request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

  • body (dict) –

    • request body, if applicable

    • default: {} (empty)

Returns:

  • response body

Return type:

dict | list

patch(token: OAuthToken, endpoint: str, params: dict = {}, body: dict = {}) dict | list[source]
  • sends a PATCH request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

  • body (dict) –

    • request body, if applicable

    • default: {} (empty)

Returns:

  • response body

Return type:

dict | list

post(token: OAuthToken, endpoint: str, params: dict = {}, body: dict = {}) dict | list[source]
  • sends a POST request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

  • body (dict) –

    • request body, if applicable

    • default: {} (empty)

Returns:

  • response body

Return type:

dict | list

put(token: OAuthToken, endpoint: str, params: dict = {}, body: dict = {}) dict | list[source]
  • sends a PUT request to the OAuth2 API

Parameters:
  • token (auth.OAuthToken) –

    • authentication token

  • endpoint (str) –

    • desired endpoint

    • base URL is optional

    • leading forward slash is optional

    • trailing parameters are optional, e.g. ?param1=true&param2=0

  • params (dict) –

    • request parameters, if applicable

    • if you put parameters at the end of the endpoint, do not put them here or they will be duplicated

  • body (dict) –

    • request body, if applicable

    • default: {} (empty)

Returns:

  • response body

Return type:

dict | list