> ## 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.

# List Datasets

> Retrieve a list of delivered [Datasets](/core-resources/dataset) with their IDs and names.

<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
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:
    get:
      tags:
        - v2
      summary: List Datasets
      description: >-
        Retrieve a list of delivered [Datasets](/core-resources/dataset) with
        their IDs and names.
      operationId: getDatasets
      responses:
        '200':
          description: List of datasets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDatasetsResponse'
              examples:
                Sample Datasets:
                  value:
                    datasets:
                      - id: dataset_abc123
                        name: Dataset 1
                      - id: dataset_def456
                        name: Dataset 2
        '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_...'
            curl --request GET \
                --url "https://api.scale.com/v2/datasets" \
                --header "Authorization: Bearer $API_KEY"
        - lang: python
          label: Python SDK
          source: |
            import scaleapi

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

            response = client.v2.get_datasets()
            print(response.to_json())
        - lang: python
          label: Python
          source: |
            import requests

            API_KEY = 'live_...'

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

            const response = await fetch('https://api.scale.com/v2/datasets', {
              method: 'GET',
              headers: {
                Accept: 'application/json',
                Authorization: `Bearer ${API_KEY}`,
              },
            });
            console.log(await response.json());
        - lang: go
          label: Go
          source: |
            package main

            import (
              "fmt"
              "net/http"
              "io/ioutil"
            )

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

              url := "https://api.scale.com/v2/datasets"

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

              req.Header.Add("Accept", "application/json")
              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: |
            import com.mashape.unirest.http.*;
            import com.mashape.unirest.http.exceptions.*;

            public class Main {
                public static void main(String[] args) throws UnirestException {
                    String apiKey = "live_...";

                    String url = "https://api.scale.com/v2/datasets";

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

                    System.out.println(response.getBody());
                }
            }
components:
  schemas:
    GetDatasetsResponse:
      type: object
      required:
        - datasets
      properties:
        datasets:
          type: array
          items:
            $ref: '#/components/schemas/Dataset'
    Dataset:
      type: object
      required:
        - id
        - name
      properties:
        id:
          $ref: '#/components/schemas/DatasetId'
        name:
          $ref: '#/components/schemas/DatasetName'
    DatasetId:
      type: string
      description: Unique identifier for a dataset
      example: dataset_abc123
    DatasetName:
      type: string
      description: The name of the dataset
      example: My Scale Dataset
  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

````