---
title: Dataset
seo:
  title: Dataset — TypeScript SDK
  description: >-
    A collection of Example objects stored on the Judgment platform. (TypeScript
    SDK)
description: A collection of Example objects stored on the Judgment platform.
---

Datasets are retrieved via DatasetFactory.get or created via
DatasetFactory.create. Once obtained, you can iterate over
the examples directly, or add new ones.

```typescript
const dataset = await client.datasets.get("golden-set");
for (const example of dataset) {
  console.log(example.get("input"));
}
```

## Attributes

| Prop | Type | Default | Description |
| - | - | - | - |
| `name?` | `string` | - | |
| `projectId?` | `string` | - | |
| `projectName?` | `string` | - | |
| `datasetKind?` | `string` | - | |
| `examples?` | `Example[]` | - | |

***

## addExamples()

Upload examples to this dataset in batches.

```typescript
async function addExamples(examples: Example[], batchSize: number = 100): Promise<void>
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `examples` | `Example[]` | - | The examples to upload. |
| `batchSize?` | `number` | `100` | Number of examples per batch request. Defaults to 100. |

### Returns

`Promise<void>`

***

## addFromJson()

Load examples from a JSON file and add them to the dataset.

Expects the file to contain a JSON array of objects, each with
properties like `input`, `actual_output`, etc.

```typescript
async function addFromJson(filePath: string, batchSize: number = 100): Promise<void>
```

### Parameters

| Prop | Type | Default | Description |
| - | - | - | - |
| `filePath` | `string` | - | Path to the JSON file. |
| `batchSize?` | `number` | `100` | Number of examples per batch request. Defaults to 100. |

### Returns

`Promise<void>`

***

## \[Symbol.iterator]\()

Iterate over examples.

```typescript
function [Symbol.iterator](): Iterator<Example, any, any>
```

### Returns

`Iterator<Example, any, any>`
