SDK Reference
While the CLI is great for development and deployment, sometimes you need programmatic access to your secrets or Enterprise features from within your application code. The RunEnv SDKs are built exactly for this purpose.
Node.js SDK
The runenv-sdk package provides programmatic integration for supported application workloads. Prefer runenv run when process-level runtime injection is sufficient; use an SDK only when the application needs an explicit programmatic integration.
Installation
npm install runenv-sdkBasic Usage
To fetch secrets from code (if you are not using runenv run):
import { Runenv } from 'runenv-sdk';
const runenv = new Runenv({
token: process.env.RUNENV_SERVICE_TOKEN,
projectId: 'prj_123abc'
});
async function main() {
await runenv.load('production');
const credential = process.env.MY_SECRET;
if (!credential) throw new Error('MY_SECRET was not injected');
// Pass the value directly to its in-memory consumer. Never print or serialize it.
await useCredentialInMemory(credential);
}Transit Operations
Use the SDK to encrypt and decrypt sensitive application data (like PII in a database) without ever handling the encryption keys yourself.
import { Runenv } from 'runenv-sdk';
const runenv = new Runenv({
token: process.env.RUNENV_SERVICE_TOKEN
});
async function storeUserSSN(userId, ssn) {
// Encrypt the SSN using the 'pii-key' Transit Key
const ciphertext = await runenv.transit.encrypt('pii-key', ssn);
await db.users.update(userId, { ssn: ciphertext });
}
async function readUserSSN(userId) {
const user = await db.users.get(userId);
// Decrypt the SSN
const plaintext = await runenv.transit.decrypt('pii-key', user.ssn);
return plaintext;
}Python SDK
The Python SDK provides synchronous and asynchronous interfaces to the RunEnv platform.
Installation
pip install runenvBasic Usage
import os
from runenv import Runenv
client = Runenv(token=os.environ.get("RUNENV_SERVICE_TOKEN"))
# Load secrets into os.environ
client.load(project_id="prj_123abc", environment="production")
api_key = os.environ.get("API_KEY")The Python client also supports asynchronous calls. Keep tokens in the process environment or your workload identity mechanism; do not embed them in application code.