Skip to main content

Read secrets from an SDK

Read the values your application needs at runtime with the SDKs or Refine. Create and manage secrets through TaruviBase Console.

This page covers JavaScript SDK 1.5.4 and Python SDK 0.2.3.

What this page covers#

Your application reads a secret by its key. This page shows how to read one secret, how to read several in a single call, and how to check the result without exposing the value. Each example is available for the JavaScript SDK, the Python SDK, and Refine.

Secrets are read-only here. You create the type and the value in TaruviBase Console first, then read them from code.

Choose how to read#

You needUseLimit
One value by keyget (JavaScript and Python) or useOne (Refine)One key per call
Several values at oncelist (JavaScript and Python) or useList (Refine)Up to 100 keys per call

Prerequisites#

  • Create the type and value through TaruviBase Console.
  • Configure a JavaScript secrets client or Python client for 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#

import type {SecretResponse} from '@taruvi/sdk';

await secrets
.get('app_config', {app: 'APP_SLUG'})
.execute<SecretResponse>();

JavaScript execute() returns the standard response wrapper, so read the secret from its data field. 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. The JavaScript Secrets helper uses its explicit app option. All three examples above request APP_SLUG.

Retrieve several secrets#

Fetch up to 100 keys in one call. Missing or sensitivity-denied keys are omitted rather than returned with empty values.

await secrets.list(['app_config', 'feature_flags'], {
app: 'APP_SLUG',
includeMetadata: true,
});

Both SDK list() methods return the response wrapper; the requested map is in data. Values can be strings or JSON objects; check the value's shape before using it.

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.

Common mistakes#

  • Reading the wrapper instead of the value. JavaScript execute() and both SDK list() methods return the response wrapper. Read the result from its data field.
  • Expecting an error for a missing key. Missing or sensitivity-denied keys are omitted from a batch read. Check that each key you need is present.
  • Relying on the default app. A Python client substitutes its configured app_slug when app is omitted. Pass app explicitly when the scope should be obvious in code.
  • Using a key that is not exact. Use the exact existing key. The API schema caps keys at 255 characters.
  • Logging the value. Do not print, snapshot, or attach a secret value to logs, traces, tickets, or test output.
  • Reading server credentials in the browser. Refine runs in the browser. Use it only for configuration intended for that user, and read server credentials on the server.

Next steps#