Authentication & Configuration#
- saia_python.load_api_key(path: str | Path | None = None) str[source]#
Discover and return the SAIA API key.
Resolution order:
pathargument — explicit file path (.saia_apior.envformat)SAIA_API_KEYenvironment variable.saia_apiin the current working directory.saia_apiin the home directory.envin the current working directory (looks forSAIA_API_KEY=...).envin the home directory
- Parameters:
path – Optional explicit path to a
.saia_apior.envfile.- Returns:
The API key string.
- Raises:
FileNotFoundError – If
pathwas given but does not exist.ValueError – If no API key could be found anywhere.
- saia_python.load_arcana_ids() dict[str, str][source]#
Discover ARCANA IDs from
.env,config.toml, and environment variables.All sources are merged. The
"default"key is set by the highest-priority source that provides a single ARCANA ID:SAIA_ARCANA_IDin.envor environment variable[saia.arcana] defaultinconfig.tomlFirst element of
[saia.arcana] idsinconfig.tomlFirst
SAIA_ARCANA_ID_XXkey (by file/env order, not sorted)
Additional IDs from
config.tomlarrays and numbered env vars are included under their respective labels.- Returns:
"default"— the default arcana ID (if any source provides one)"0","1", … — from[saia.arcana] idsarrayNumbered suffixes (e.g.
"01") — fromSAIA_ARCANA_ID_01env vars
Returns an empty dict if no ARCANA IDs are found.
- Return type:
A dict mapping label to arcana ID string
- saia_python.load_config() dict[source]#
Load the full
config.tomlas a dict.Searches the current working directory, then the home directory.
- Returns:
The parsed TOML dict, or an empty dict if not found.
- saia_python.load_username() str | None[source]#
Discover the SAIA username from environment,
.env, orconfig.toml.Resolution order:
SAIA_USERNAMEenvironment variableSAIA_USERNAMEin.env[saia] usernameinconfig.toml
- Returns:
The username string, or
Noneif not configured.
- saia_python.resolve_base_url(explicit: str | None = None) str[source]#
Resolve the SAIA API base URL.
Resolution order: explicit parameter >
[saia] base_urlinconfig.toml> the hardcodedDEFAULT_BASE_URL.- Parameters:
explicit – An explicit URL. If provided, returned as-is (trailing slash stripped).
- Returns:
The resolved base URL string.