Skip to content
VaultLens Studio

Client libraries

VaultLens doesn’t publish an SDK package to npm, PyPI or any other registry. VaultLens maintains a TypeScript client internally, but it isn’t released, so there’s nothing to npm install. Instead, generate a client for your language from the API’s OpenAPI 3.1 document, or call the API with any HTTP client as the other guides do.

The OpenAPI document is public (no key needed) and always matches the live API, because it’s built from the same route table the API runs on:

https://api.vaultlens.studio/v1/openapi.json

It describes every endpoint, parameter, request body, response and error, and the webhook payloads. Its server URL is https://api.vaultlens.studio and its paths start with /v1, so generated clients take https://api.vaultlens.studio as their base URL. The API’s version is in info.version (currently 1.0.0). The API reference is rendered from the same document.

curl

Download the document to generate from, or to keep a copy under version control so you notice changes:

curl -s https://api.vaultlens.studio/v1/openapi.json -o vaultlens-openapi.json
jq -r '.info.version, (.paths | keys[])' vaultlens-openapi.json

Node

For TypeScript or JavaScript, openapi-typescript generates types from the document and openapi-fetch makes typed calls with them, on top of the built-in fetch (Node 18+). VaultLens’s own internal client is built this way.

npm install openapi-fetch
npx openapi-typescript https://api.vaultlens.studio/v1/openapi.json -o vaultlens.d.ts

Then create a client and add your key to every request. In TypeScript, write createClient<paths>(...) with import type { paths } from './vaultlens.js'; in plain JavaScript, the JSDoc comment below gives editors the same checking.

import createClient from 'openapi-fetch';

/** @type {import('openapi-fetch').Client<import('./vaultlens.js').paths>} */
const vl = createClient({ baseUrl: 'https://api.vaultlens.studio' });
vl.use({
  onRequest({ request }) {
    request.headers.set('Authorization', `Bearer ${process.env.VAULTLENS_API_KEY}`);
    return request;
  },
});

// Each call returns { data, error, response }: data on success, error holds the API's error body.
const { data: apps, error } = await vl.GET('/v1/apps');
if (error) throw new Error(`${error.error.code}: ${error.error.message}`);
const appId = apps.data.find((a) => a.name === 'Sales CRM')?.id;
if (!appId) throw new Error('App not found.');

// Path parameters, query parameters and headers are typed from the document.
const records = await vl.GET('/v1/apps/{appId}/tables/{table}/records', {
  params: {
    path: { appId, table: 'object_1' },
    query: { limit: 100, filter: JSON.stringify([{ column: 'status', op: 'eq', value: 'Open' }]) },
  },
});
if (records.error) throw new Error(`${records.error.error.code}: ${records.error.error.message}`);
console.log(
  records.data.columns.map((c) => c.column),
  records.data.data.length,
);

// Reusing an Idempotency-Key returns the first job instead of starting another.
const today = new Date().toISOString().slice(0, 10);
const started = await vl.POST('/v1/apps/{appId}/reconcile', {
  params: { path: { appId }, header: { 'Idempotency-Key': `nightly-sync-${today}` } },
});
if (started.error) throw new Error(`${started.error.error.code}: ${started.error.error.message}`);
console.log(started.data.jobId);

Regenerate vaultlens.d.ts when the document’s info.version changes. For webhook signature checks, use the function in webhooks; generated clients don’t include one.

Python

Python generators that read OpenAPI 3.1 include openapi-python-client and openapi-generator’s python generator. Check that the generated package imports cleanly before relying on it: in our testing, openapi-python-client 0.30.0 generated a model with a syntax error from this document (the archive dry-run response).

For most integrations a small wrapper around requests is enough, and it’s what the Python samples in these guides use:

import os

import requests


class VaultLens:
    """A minimal client: one method per HTTP verb, errors raised with the API's code."""

    def __init__(self, api_key=None, base_url="https://api.vaultlens.studio/v1"):
        self.base_url = base_url
        self.session = requests.Session()
        self.session.headers["Authorization"] = f"Bearer {api_key or os.environ['VAULTLENS_API_KEY']}"

    def request(self, method, path, idempotency_key=None, **kwargs):
        headers = kwargs.pop("headers", {})
        if idempotency_key:
            headers["Idempotency-Key"] = idempotency_key
        res = self.session.request(method, self.base_url + path, headers=headers, timeout=60, **kwargs)
        if not res.ok:
            err = res.json()["error"]
            raise RuntimeError(f"{res.status_code} {err['code']}: {err['message']} ({err['requestId']})")
        return res.json() if "json" in res.headers.get("Content-Type", "") else res.content

    def get(self, path, **params):
        return self.request("GET", path, params=params)

    def post(self, path, body=None, idempotency_key=None):
        return self.request("POST", path, idempotency_key=idempotency_key, json=body)

    def paginate(self, path, **params):
        """Yields every item of a paged list (jobs, archive runs, records)."""
        while True:
            page = self.get(path, **params)
            yield from page["data"]
            if not page["nextCursor"]:
                return
            params["cursor"] = page["nextCursor"]


if __name__ == "__main__":
    vl = VaultLens()
    for app in vl.get("/apps")["data"]:
        print(app["id"], app["name"])
    for job in vl.paginate("/jobs", limit=100):
        print(job["id"], job["type"], job["state"])

Add retries for 429 and 5xx as shown in errors and rate limits.

Other languages

Any generator that supports OpenAPI 3.1 can work from the same document. Point it at https://api.vaultlens.studio/v1/openapi.json, set the base URL to https://api.vaultlens.studio, and configure bearer authentication with your API key. A few things generators handle differently:

  • POST /apps/<appId>/archive-configs/<configId>/run returns one of two shapes (a job id, or a dry-run estimate) under the same 202 status.
  • GET /archive-runs/<runId>/files/<fileId>/download returns text/csv, not JSON.
  • Nullable fields are written as "type": ["string", "null"], the OpenAPI 3.1 form.

If you’d rather not write code at all, VaultLens for AI connects AI assistants to the same data.