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

# Listing Datasets

> List all datasets

<Warning>Using the API directly is not recommended for most users. Instead, we recommend using the [Python SDK](/python-sdk/setup).</Warning>

List all datasets.

## Headers

<ParamField header="Authorization" type="string" required>
  Your Sutro API key using Key authentication scheme.

  Format: `Key YOUR_API_KEY`

  Example: `Authorization: Key sk_live_abc123...`
</ParamField>

## Response

Returns a JSON object containing a list of datasets.

<ResponseField name="datasets" type="array">
  A list of datasets you have access to. Each dataset object contains metadata about the dataset including dataset\_id, name, creation time, and other relevant information.
</ResponseField>

<ResponseExample>
  ```json Datasets List Response theme={null}
  {
    "datasets": [
      {
        "dataset_id": "dataset_12345",
        "name": "Training Data Q1 2024",
        "created_at": "2024-01-15T10:30:00Z",
        "file_count": 5,
        "total_size_bytes": 1048576,
        "schema": {
          "fields": [
            {"name": "input", "type": "string"},
            {"name": "output", "type": "string"},
            {"name": "category", "type": "string"}
          ]
        }
      },
      {
        "dataset_id": "dataset_12346",
        "name": "Evaluation Dataset",
        "created_at": "2024-01-20T14:15:00Z",
        "file_count": 2,
        "total_size_bytes": 524288,
        "schema": {
          "fields": [
            {"name": "prompt", "type": "string"},
            {"name": "response", "type": "string"}
          ]
        }
      }
    ]
  }
  ```
</ResponseExample>

## Code Examples

<CodeGroup>
  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.sutro.sh/list-datasets',
      headers={
          'Authorization': 'Key YOUR_SUTRO_API_KEY'
      }
  )

  result = response.json()
  print(f"Found {len(result['datasets'])} datasets:")

  for dataset in result['datasets']:
      print(f"Dataset ID: {dataset['dataset_id']}")
      print(f"Name: {dataset['name']}")
      print(f"Created: {dataset['created_at']}")
      print(f"Files: {dataset['file_count']}")
      print(f"Size: {dataset['total_size_bytes']} bytes")
      print("---")
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.sutro.sh/list-datasets', {
    method: 'POST',
    headers: {
      'Authorization': 'Key YOUR_SUTRO_API_KEY'
    }
  });

  const result = await response.json();
  console.log(`Found ${result.datasets.length} datasets:`);

  result.datasets.forEach(dataset => {
    console.log(`Dataset ID: ${dataset.dataset_id}`);
    console.log(`Name: ${dataset.name}`);
    console.log(`Created: ${dataset.created_at}`);
    console.log(`Files: ${dataset.file_count}`);
    console.log(`Size: ${dataset.total_size_bytes} bytes`);
    console.log('---');
  });
  ```

  ```curl cURL theme={null}
  curl -X POST https://api.sutro.sh/list-datasets \
    -H "Authorization: Key YOUR_SUTRO_API_KEY"
  ```
</CodeGroup>

## Dataset Object Fields

Each dataset in the `datasets` array contains the following fields:

* `dataset_id`: Unique identifier for the dataset
* `name`: Human-readable name of the dataset
* `created_at`: ISO timestamp of when the dataset was created
* `file_count`: Number of files in the dataset
* `total_size_bytes`: Total size of all files in the dataset (in bytes)
* `schema`: Schema information including field names and types

## Notes

* Datasets are returned in reverse chronological order (newest first)
* The response includes metadata about each dataset to help with dataset management
* Use the `dataset_id` from this response with other dataset-related endpoints
