Read secrets from an SDK
Use an SDK to read values your application needs at runtime. The SDKs
are read-only: JavaScript and Python expose get and list, but neither
SDK exposes secret or secret-type creation, editing, deletion, or history.
This page covers JavaScript SDK 1.5.3 and Python SDK 0.2.1. The Python
package installs as version 0.2.1, although taruvi.__version__ reports
0.1.9.
Prerequisites
- Create the type and value through TaruviBase Console.
- Configure a JavaScript
secretsclient or Pythonclientfor the intended site and app. See JavaScript or Python. - Use the exact existing key. The API schema caps keys at 255 characters.
Read one secret
- JavaScript SDK
- Python SDK
import type {SecretResponse} from '@taruvi/sdk';
const response = await secrets
.get('app_config')
.execute<SecretResponse>();
const secret = response.data;
secret = client.secrets.get("app_config", app="APP_SLUG")
JavaScript execute() returns the standard response wrapper, so read the
secret from response.data. Python get() returns the extracted secret object.
A Python client substitutes its configured app_slug when app is omitted;
pass the app explicitly when scope must be obvious in code.
Retrieve several secrets
Fetch up to 100 keys in one call. Missing or sensitivity-denied keys are omitted rather than returned with empty values.
- JavaScript SDK
- Python SDK
const resultsResponse = await secrets.list(['app_config', 'feature_flags'], {
includeMetadata: true,
});
const results = resultsResponse.data;
results_response = client.secrets.list(
keys=["app_config", "feature_flags"],
include_metadata=True,
)
results = results_response["data"]
Both SDK list() methods return the response wrapper; the requested map is in
data. JavaScript SDK 1.5.3 declares string-only batch value types, although
the service can return strings or JSON objects. Python's Secret type hint
omits the value returned by get(). Treat both as typing limitations.
Verify without exposing values
Check that the expected keys are present and that the value has the expected type. Do not print, snapshot, or attach the value to logs, traces, tickets, or test output. If a key is missing, confirm site/app scope and sensitivity before retrying.