> ## Documentation Index
> Fetch the complete documentation index at: https://docs.genai.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get a Dataset Task

> Retrieve a [Dataset Task](/core-resources/dataset-task) from its `task_id`.

<Accordion title="Authentication" icon="key">
  Every request sent to Scale's API requires authentication. In short, your API Key is the Bearer token. See the [Authentication](/get-started/authentication) section for more details.
</Accordion>


## OpenAPI

````yaml GET /v2/datasets/task
openapi: 3.1.0
info:
  title: GenAI API Spec
  description: 'Data Engine: Generative AI API Specification'
  version: 0.0.1
servers:
  - url: https://api.scale.com
security:
  - bearerAuth: []
  - basicAuth: []
paths:
  /v2/datasets/task:
    get:
      tags:
        - v2
      summary: Get a Dataset Task
      description: >-
        Retrieve a [Dataset Task](/core-resources/dataset-task) from its
        `task_id`.
      operationId: getDatasetTask
      parameters:
        - $ref: '#/components/parameters/task_id'
        - $ref: '#/components/parameters/datasets_expand_task'
      responses:
        '200':
          description: Complete task.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDatasetTaskResponse'
              examples:
                Sample Dataset Task:
                  $ref: '#/components/examples/SampleDatasetTask'
        '500':
          description: Error response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status_code:
                    type: number
                    example: 500
                  error:
                    type: string
                    example: An error has occurred.
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |
            API_KEY='live_...'
            TASK_ID='abc123'
            curl --request GET \
                --url "https://api.scale.com/v2/datasets/task?task_id=$TASK_ID" \
                --header "Authorization: Bearer $API_KEY"
        - lang: python
          label: Python SDK
          source: |
            import scaleapi

            API_KEY = 'live_...'
            client = scaleapi.ScaleClient(API_KEY)

            TASK_ID = 'abc123'
            response = client.v2.get_dataset_task(TASK_ID)
            print(response.to_json())
        - lang: python
          label: Python
          source: |
            import requests

            API_KEY = 'live_...'
            TASK_ID = 'abc123'

            response = requests.request(
              "GET",
              url="https://api.scale.com/v2/datasets/task",
              params={"task_id": TASK_ID},
              headers={
                "Accept": "application/json",
                "Authorization": f"Bearer {API_KEY}",
              },
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >
            const API_KEY = 'live_...';

            const TASK_ID = 'abc123';


            const params = new URLSearchParams({ task_id: TASK_ID });


            const response = await
            fetch('https://api.scale.com/v2/datasets/task?' + params.toString(),
            {
              method: 'GET',
              headers: {
                Accept: 'application/json',
                Authorization: `Bearer ${API_KEY}`,
              },
            });

            console.log(await response.json());
        - lang: go
          label: Go
          source: |
            package main

            import (
              "fmt"

              "io/ioutil"
              "net/http"
            )

            func main() {
              apiKey := "live_..."
              taskId := "abc123"

              url := fmt.Sprintf("https://api.scale.com/v2/datasets/task?task_id=%s", taskId)

              req, _ := http.NewRequest("GET", url, nil)

              req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", apiKey))

              res, _ := http.DefaultClient.Do(req)

              defer res.Body.Close()
              body, _ := ioutil.ReadAll(res.Body)

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: |
            package com.scale.api;

            import kong.unirest.HttpResponse;
            import kong.unirest.Unirest;

            public class App {
                public static void main(String[] args) {
                    String apiKey = "live_...";
                    String taskId = "abc123";

                    String url = String.format("https://api.scale.com/v2/datasets/task?task_id=%s", taskId);

                    HttpResponse<String> response = Unirest.get(url)
                      .header("Authorization", String.format("Bearer %s", apiKey))
                      .asString();

                    System.out.println(response.getBody());
                }
            }
components:
  parameters:
    task_id:
      name: task_id
      in: query
      required: true
      description: Scale's unique identifier for the task.
      schema:
        $ref: '#/components/schemas/TaskId'
    datasets_expand_task:
      name: expand
      in: query
      required: false
      description: >-
        List of fields to [expand](/api-reference/expanding-entities) in the
        response.
      schema:
        $ref: '#/components/schemas/ExpandDatasetTask'
  schemas:
    GetDatasetTaskResponse:
      $ref: '#/components/schemas/DatasetTask'
    TaskId:
      type: string
      description: Unique identifier for a task
      example: task_abc123
    ExpandDatasetTask:
      type: array
      description: >-
        List of fields to [expand](/api-reference/expanding-entities) in the
        response.
      items:
        $ref: '#/components/schemas/ExpandableEnumDatasetTask'
    DatasetTask:
      type: object
      required:
        - task_id
        - dataset
        - delivery
        - response
      properties:
        task_id:
          $ref: '#/components/schemas/TaskId'
          description: Unique identifier for the task.
        dataset:
          $ref: '#/components/schemas/ExpandableDataset'
          description: >-
            Dataset ID or [Dataset](/core-resources/dataset) associated with the
            task.
        delivery:
          $ref: '#/components/schemas/ExpandableDatasetDelivery'
          description: >-
            Delivery ID or [Delivery](/core-resources/dataset-delivery)
            associated with the task.
        response:
          $ref: '#/components/schemas/DatasetResponse'
    ExpandableEnumDatasetTask:
      type: string
      description: Entities that can be expanded from an ID to an object.
      enum:
        - dataset
        - delivery
    ExpandableDataset:
      description: >-
        Dataset ID or [Dataset](/core-resources/dataset) associated with the
        task.
      oneOf:
        - $ref: '#/components/schemas/DatasetId'
        - $ref: '#/components/schemas/Dataset'
    ExpandableDatasetDelivery:
      description: >-
        Delivery ID or [Delivery](/core-resources/dataset-delivery) associated
        with the task.
      oneOf:
        - $ref: '#/components/schemas/DatasetDeliveryId'
        - $ref: '#/components/schemas/DatasetDelivery'
    DatasetResponse:
      type: object
      description: Response associated with the dataset task.
      additionalProperties: true
    DatasetId:
      type: string
      description: Unique identifier for a dataset
      example: dataset_abc123
    Dataset:
      type: object
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/DatasetId'
        name:
          $ref: '#/components/schemas/DatasetName'
    DatasetDeliveryId:
      type: string
      description: Unique identifier for a delivery
      example: delivery_abc123
    DatasetDelivery:
      type: object
      required:
        - id
        - name
        - delivered_at
        - metadata
      properties:
        id:
          $ref: '#/components/schemas/DatasetDeliveryId'
        name:
          type: string
          description: The name of the delivery
          example: My Delivery - 2024-01-15
        delivered_at:
          $ref: '#/components/schemas/DateString'
          description: UTC timestamp when the delivery was created.
        dataset:
          $ref: '#/components/schemas/ExpandableDataset'
        metadata:
          $ref: '#/components/schemas/DatasetDeliveryMetadata'
    DatasetName:
      type: string
      description: The name of the dataset
      example: My Scale Dataset
    DateString:
      type: string
      format: date-time
      description: A timestamp formatted as an ISO 8601 date-time string.
    DatasetDeliveryMetadata:
      type: object
      properties:
        task_count:
          type: integer
          description: The number of tasks in the delivery
          example: 1000
        turn_count:
          type: integer
          description: The number of turns in the delivery
          example: 1000
  examples:
    SampleDatasetTask:
      value:
        task_id: task_123
        delivery: delivery_123
        dataset: dataset_123
        response:
          key_1: value_1
          key_2: value_2
  securitySchemes:
    bearerAuth:
      description: >-
        Your API Key is the Bearer token. See the
        [Authentication](/get-started/authentication) section to learn how to
        access your key.
      type: http
      scheme: bearer
    basicAuth:
      description: >-
        Basic HTTP Authentication. Your API Key is your username.  Learn more
        about setting up Authentication [here](/get-started/authentication).
      type: http
      scheme: basic

````