The official Python client for the XtraSecurity API. Built with native caching, type hints, and Zero-Trust injection.
The SDK provides a primary wrapper class, XtraClient. It accepts an XtraClientOptions object during instantiation.
| Option | Type | Default | Description |
|---|---|---|---|
| token | str | os.environ['XTRA_TOKEN'] | The API Token used for authentication. |
| project_id | str | os.environ['XTRA_PROJECT_ID'] | The default project ID for all secret operations. |
| api_url | str | https://www.xtrasecurity.in/api | Override the base URL for self-hosted Enterprise instances. |
| cache | bool | True | Enables in-memory caching to prevent rate-limiting. |
| cache_ttl | int | 30 | Time-to-live for cached secrets in seconds. |
Fetches all secrets for a specific environment and branch, returning a standard dictionary. This method automatically utilizes the in-memory cache if enabled.
| Parameter | Type | Description |
|---|---|---|
| env | str | Required. The target environment (e.g. 'production'). |
| project_id | str | Optional override for the default project_id. |
| branch | str | Optional. Target a specific environment branch (defaults to 'main'). |
| no_cache | bool | Optional. If True, forces a network request bypassing the in-memory cache. |
A convenience method that fetches secrets and immediately populates os.environ. This is the recommended approach for standard Python web applications like Flask or Django.
Manually flushes the in-memory secret cache.
For power users building custom internal tools, XtraClient exposes the raw auto-generated service classes.
All internal SDK errors are thrown as instances of the XtraError exception class.