Skip to main content
Every public symbol exported by westyx_nexus. Both NexusClient (sync) and AsyncNexusClient (async) share the same read API - only the lifecycle methods (sync, connect_stream, close) differ.

Construction

NexusClient.create(config: NexusConfig) -> NexusClient

Synchronous factory. Performs a blocking initial sync.

await AsyncNexusClient.create(config: NexusConfig) -> AsyncNexusClient

Async factory. Same blocking initial sync semantics, but expressed as a coroutine.

Configs

nexus.get_config(key: str, default: Any = None) -> Any

Returns the resolved config value as Any (the wire-decoded JSON value), or default if the key is absent.

nexus.get_config_as(key: str, type_: type[T], default: T | None = None) -> T | None

Returns the config value coerced to the given type, using a standard call (type_(value)).

nexus.get_all_configs() -> dict[str, Any]

Snapshot copy of every config key-value pair currently in the cache.

Feature flags

nexus.get_flag(key: str, default: bool = False) -> bool

Returns the is_active state of a flag, or default when the key is absent.

nexus.get_all_flags() -> dict[str, bool]

Snapshot copy of every flag key-is_active pair in the cache.

AB Testing (v0.3.0)

nexus.find_flag(key: str) -> bool | None

Returns the flag’s is_active state, or None when the flag is not in the cache at all. get_flag answers False both for a flag that is off and for one that does not exist. Anything that has to tell those apart - an OpenFeature provider answering FLAG_NOT_FOUND, or a startup check that a flag key is spelled the way the console spells it - needs find_flag. get_flag is expressed in terms of it, so the two cannot drift.
Available on AsyncNexusClient with the same signature.

nexus.evaluate_ab(keys: list[str], user_id: str, attributes: dict[str, Any]) -> dict[str, bool]

Batch-evaluate AB Testing flags for a given user. Issues a single POST /v1/flags/evaluate-ab request; the server applies each flag’s rollout / targeting rules to the supplied user_id and attributes, and returns a key -> bool map. Unlike get_flag, this is a network call - the result depends on user_id, so it cannot be served from the local snapshot cache. Attribute values must be strings. Cohort conditions compare them as strings with eq / neq / in, so a non-string value raises TypeError naming the attribute and the type that arrived, before the request is sent. Nothing is stringified: no conversion is lossless, and a value that silently matches no rule is harder to diagnose than one that was refused. A None value is treated as unset and dropped rather than kept as "", which could satisfy an eq "" rule.

Secrets (secret key only)

nexus.get_secret(key: str) -> str

Returns the plaintext value of a text-type secret.

nexus.get_secret_file_path(key: str) -> str | None (v0.3.0)

Returns the on-disk path of a file-type secret, or None. The SDK materialises the value as a file in a private per-client directory and exposes the absolute path here:
Both the key and the value are hashed - the secret’s name never appears on the filesystem. The directory scopes every path to one client, so two clients holding the same secret do not share a file. The file is created with mode 0600. See File-type secret security for the full guarantees and lifecycle.
Returns None for text-type secrets, unknown keys, or when the on-disk write failed - fall back to get_secret for text-type values.

Secrets - Write API (v0.5.0) (secret key only)

Since v0.15.0 these three methods are available on AsyncNexusClient too, with the same signatures, as coroutines: await async_nexus.set_secret(...), await async_nexus.delete_secret(...), await async_nexus.delete_secret_version(...).

nexus.set_secret(key: str, value: str, secret_type: str = "text") -> None

Creates or updates a secret with the given key and value.

nexus.delete_secret(key: str) -> None

Deletes a secret by key.

nexus.delete_secret_version(key: str, version: int) -> None (v0.5.0)

Deletes a specific version of a secret.

Metadata

Sync / lifecycle (sync API)

nexus.sync() -> None

Forces a sync now, bypassing the TTL. Rarely needed - the SDK syncs automatically.

nexus.connect_stream() -> None / nexus.disconnect_stream() -> None

Start/stop the SSE thread. The SDK calls connect_stream() automatically after the initial sync (unless stream=False in config). Idempotent.

nexus.close() -> None

Stops the SSE thread and releases the underlying HTTP client. Always call on shutdown (or use a with block).

Sync / lifecycle (async API)

The async client has matching coroutine versions:
Use async with await AsyncNexusClient.create(config) as nexus: for guaranteed cleanup.

Error types

All fourteen are exported from the package root:

Logger interface

A duck-typed Protocol - any object with these three methods qualifies. The SDK ships a StdlibNexusLogger adapter that forwards to the stdlib logging module.