1. Get a key and install
Generate an API key, then create a local project: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 asclient.ts. createClient() takes explicit configuration; this module reads the environment variables for it.
client.ts
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 asmain.ts to read your identity with client.me() and iterate through projects with projects.listAll():
main.ts
.env as TOLOKA_PROJECT_ID. If the list is empty, create a project first.
4. Create fields and append rows
Append this code tomain.ts. It creates a dataset, defines its fields, and appends two rows:
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.
5. Export and read the download link
Append this code to the same script to start an export and poll for completion withwaitFor():
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.