Skip to main content
GET
/
v2
/
datasets
/
tasks
API_KEY='live_...'
PARAMS='dataset_id=my_dataset_123&limit=1'
curl --request GET \
--url "https://api.scale.com/v2/datasets/tasks?$PARAMS" \
--header "Authorization: Bearer $API_KEY"
{
  "tasks": [
    {
      "task_id": "task_123",
      "delivery": "delivery_123",
      "dataset": "dataset_123",
      "response": {
        "key_1": "value_1",
        "key_2": "value_2"
      }
    }
  ],
  "next_token": "imatoken123"
}
Every request sent to Scale’s API requires authentication. In short, your API Key is the Bearer token. See the Authentication section for more details.

Required query parameters

You are expected to provide one of the following to start downloading tasks:
  • Dataset (dataset_id)
  • Delivery (delivery_id)

Example Code

# Downloads all tasks from a dataset
import json
import requests


API_KEY = 'live_...'
DATASET_ID = 'MY DATASET ID'

def get_tasks_by_dataset(dataset_id: str):
    tasks = []
    params = {
        "dataset_id": dataset_id,
    }

    should_fetch = True

    while should_fetch:
        response = requests.request(
            "GET",
            url="https://api.scale.com/v2/datasets/tasks",
            params=params,
            headers={
                "Accept": "application/json",
                "Authorization": f"Bearer {API_KEY}",
            },
        )
        json_resp = response.json()

        next_token = json_resp.get('next_token')
        if next_token:
            params['next_token'] = next_token
        else:
            should_fetch = False

        tasks.extend(json_resp['tasks'])

    return tasks


if __name__ == "__main__":
    tasks = get_tasks_by_dataset(DATASET_ID)

    with open(f'dataset_{DATASET_ID}_tasks.jsonl', 'w+') as f:
        for task in tasks:
            json.dump(task, f)
            f.write('\n')

Authorizations

Authorization
string
header
required

Your API Key is the Bearer token. See the Authentication section to learn how to access your key.

Query Parameters

dataset_id
string

Scale's unique identifier for the dataset.

Example:

"dataset_abc123"

delivery_id
string

Scale's unique identifier for the delivery.

Example:

"delivery_abc123"

delivered_after
string<date-time>

Deliveries with a delivered_at after the given date will be returned. A timestamp formatted as an ISO 8601 date-time string.

delivered_before
string<date-time>

Deliveries with a delivered_at before the given date will be returned. A timestamp formatted as an ISO 8601 date-time string.

limit
integer

Limit the number of entities returned.

Required range: 1 <= x <= 100
next_token
string

A token used to retrieve the next page of results if there are more. You can find the next_token in your last request.

expand
enum<string>[]

List of fields to expand in the response.

Response

List of delivered tasks.

tasks
object[]
required
next_token
string

A token used to retrieve the next page of results if there are more. You can find the next_token in your last request

I