Skip to main content
Use Bun 1.4.0 or newer and a platform account with write access to a project. This walkthrough creates a dataset and adds two rows each time you run the finished script.

1. Get a key and install

Generate an API key, then create a local project:
Set TOLOKA_API_KEY through your shell or secret manager. You can also put it in a local .env file, which Bun loads. Keep that file out of version control:
.env

2. Create a client

Save this as client.ts. createClient() takes explicit configuration; this module reads the environment variables for it.
client.ts
Use the platform origin for baseUrl; the SDK adds /api/v2-beta to requests. See client configuration for other credentials and custom fetch functions.

3. Check your identity and projects

Save this as main.ts to read your identity with client.me() and iterate through projects with projects.listAll():
main.ts
Run it:
Pick a project you can write to and add its ID to .env as TOLOKA_PROJECT_ID. If the list is empty, create a project first.

4. Create fields and append rows

Append this code to main.ts. It creates a dataset, defines its fields, and appends two rows:
Pass fields on the append call to map each row’s keys into those fields. Omitting it stores each whole row under uploaded, even if other fields already exist. Inline appends accept up to 10,000 rows and a 2 MiB request body; use the dataset upload flow for larger files. Append this code to the same script to start an export and poll for completion with waitFor():
Run bun run main.ts again to execute the complete workflow. The download contains a JSON array with the selected dataset fields. For timeout and failure handling, see long-running jobs and errors.