APIs ‐ All APIs - altoiddealer/ad_discordbot GitHub Wiki

This section of the dict_api_settings.yaml configuration defines a list of ALL APIs/endpoints including ones being used for main functions, and non-main bot functions (via the Tags system / "user commands", etc)

Screenshot

Screenshot 2025-06-09 164928

Usage Instructions:

Create a list of APIs by duplicating / editing the examples, and referring to information below.

Client Parameters

Parameter Value Type Description Default
name string The name to be linked to bot functions / tags / workflow steps Required
enabled bool Whether the API should initialize enabled. Can be toggled during runtime via /toggle_api True
url string The base URL path. Endpoints will complete the routing path Required
default_headers dict Set the default headers for all endpoints. Can be overridden by Endpoints {Content-Type: application/json}
default_timeout int Set the default timeout for all endpoints. Can be overridden by Endpoints 60
auth dict Expected format: {username: myuser, password: mypass}. Uses aiohttp.BasicAuth() None
websocket dict Configuration for a websocket connection. More details below. None
endpoints list A list of Endpoint definitions (dictionaries). More details below []

Client Websocket Config

There are many dynamic options that can be used in the websocket Client parameter dictionary value.

Click to Expand Screenshot 2025-06-09 210313
Parameter Value Type Description Default
url string Full WebSocket URL; fallback to HTTP-based connection if omitted None
client_id_required bool Whether a client ID must be appended to the connection URL False
client_id_format string Format for generated client ID: uuid, short, timestamp, hex, etc. uuid
token_required bool Whether a token is required in the URL False
token_name string The query param key used to pass the token (e.g., "token", "auth") token
auth_token string Token value if token_required is True None
session_id_required bool Whether a session ID is required for reconnect/resume False
session_id_name string The query param key used for the session ID session_id
session_id string Session ID value if required None
channel_required bool Whether a channel/room must be specified False
channel_name string The query param key used for the channel channel
channel string The channel value if required None
version_required bool Whether a version must be passed False
version_name string The query param key used for the version version
version string Version value if required None
headers dict Optional headers sent during the WebSocket connection {}
query_params dict Key-value pairs turned into query string (?key=val...) {}
reconnect_on_failure bool Whether to auto-reconnect on connection failure True
retry int Number of retry attempts if reconnecting 1

Dynamic Query Parameter Placeholders

Dynamic placeholders can be used anywhere within the WebSocket configuration, including inside query_params, url, headers, and even within payload values. These placeholders follow the format {placeholder_name} and are automatically resolved to their actual values at runtime when:

  • The client is initialized via the script

  • The client is toggled on via /toggle_api

This allows for flexible and dynamic configuration without hardcoding runtime values.

Example usage:

headers:
  Authorization: "Bearer {token}"
query_params:
  client_id: "{client_id}"
  token: "{token}"
  version: "{version}"
  session_id: "{session_id}"
  channel: "{channel}"
  app_name: "MyApp"
  debug: "1"

Supported Dynamic Placeholders:

Placeholder Description Source
{client_id} Auto-generated or user-supplied client ID Based on client_id_format or user set
{token} Authorization token if token_required is true Provided via config or runtime override
{session_id} Session identifier for reconnect/resume logic Set via config or dynamically generated
{channel} Channel or topic name Optional; tied to channel_required
{version} API version value Used when version_required is true

Endpoint Parameters

Parameter Value Type Description Default
name string The name to be linked to bot functions / tags / workflow steps Required
path string Completes the url from the client url to the endpoint route. Can include one or more {} which can have dynamic values formatted into it via the path_vars parameter (ex: path: "/history/{}"
method string GET / POST / PUT Tip: If value is null (None), calling the Endpoint will simply "return" the payload. Useful for creating your own API responses locally and feeding preconfigured information into response_handling "GET"
headers dict Will override default_headers if set in Client {Content-Type: application/json}
timeout int Will override default_timeout if set in Client 60
retry int Number of times to retry on failure 0
concurrency_limit int Limits the number of simultaneous requests being executed by an Endpoint None
response_type string Recommended for POST/PUT methods. Valid types: json / text / bytes / binary / image / base64 / base64_json / csv / yaml / html "json"
payload_type string Valid types: json / form / multipart / query / any. If not specified, bot will try to infer the correct type "any"
payload_base string / dict The base payload that may be updated by the bot before submitting to API. Read about the bot's Payload Injection method. Value can be: (1.) Filename for a .json / .yaml / .yml in /user/payloads/ (2.) A dictionary value (3.) The name of another Endpoint with a "GET" method None
stream bool Whether response is streaming. Not yet implemented False
response_handling list A list of processing steps executed on every response from the endpoint, using StepExecutor. Can be extended via Workflows. []

⚠️ **GitHub.com Fallback** ⚠️