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

# Build Your First Dataset

> Go from one sentence to a filled, sourced table in the playground, then do the same from code

This guide builds a small dataset in the playground, then shows the same flow with the CLI and the API. It takes about
15 minutes, most of it waiting for the run.

> [!NOTE]
>
> Each build or populate uses one of your 3 beta runs per rolling 24 hours, across the playground, CLI, and API. Pick
> one path below rather than running all three.

## In the Playground

**1. Open the Datasets playground**

Sign in and open [agent.tinyfish.ai/playground/datasets](https://agent.tinyfish.ai/playground/datasets).

**2. Describe the dataset**

Type what you want as one sentence: the kind of thing each row is, where or which ones, and the fields you need.

```text theme={null}
Specialty coffee shops in Oakland with their website, neighborhood, and Google rating
```

Click **Build**. TinySet plans the columns from your sentence, which can take up to a minute.

![Datasets playground with a prompt for Oakland coffee shops typed in and the Build button](https://mintcdn.com/tinyfish/tZ8pK24QLFUf3bSL/images/datasets/prompt.png?fit=max\&auto=format\&n=tZ8pK24QLFUf3bSL\&q=85\&s=14d0811c4879fb27ec7d19810e609970)

**3. Confirm the schema**

Check the planned columns before anything runs:

![Confirm the schema dialog listing columns with their type, name, PK badge, and description, plus the Rows field and Build dataset button](https://mintcdn.com/tinyfish/tZ8pK24QLFUf3bSL/images/datasets/review-columns.png?fit=max\&auto=format\&n=tZ8pK24QLFUf3bSL\&q=85\&s=20f8d35ba50eaa10a1ed1339306505ee)

* **Name** the dataset.
* **Edit columns.** Rename them, change their type, or add an optional description that tells TinySet where to
  look for the value.
* **Primary key.** Click **PK** to mark at least one column as the primary key. It decides when two rows are the same
  thing, so pick something unique to each one, like a website or street address. A name alone can merge two
  locations of the same chain.
* **Filter.** Mark a yes/no column as the filter to keep only rows where it is true, such as "Has a roaster on
  site".
* **Rows.** Set how many rows to fill to, from 1 to 250. Start with 25 to see results sooner.

Click **Build dataset**.

**4. Watch it fill**

Rows appear in the table as TinySet finds them. A run usually takes 5 to 20 minutes, and you can leave the page and
come back. Your datasets are listed under **Your datasets**.

**5. Use the results**

Click **Settings** on the dataset to:

![A filled dataset table of TinyFish events with the Settings menu open showing Share, Max rows, and Delete and populate](https://mintcdn.com/tinyfish/tZ8pK24QLFUf3bSL/images/datasets/dataset-table.png?fit=max\&auto=format\&n=tZ8pK24QLFUf3bSL\&q=85\&s=d064fd2d8a1c1d7271cf05cb6b5d9219)

* **Share** to turn on a read-only link. Anyone with the link can view the table.
* **Max rows** to change the row target.
* **Delete and populate** to empty the table and fill it again from scratch.

## Write a Good Prompt

* **Name the entity.** "Coffee shops" works better than "coffee in Oakland". Each row should be one thing.
* **Scope it.** Add a place, a date range, or a category: "opened since 2024", "in the Bay Area", "Series A only".
* **List the fields.** Every field you name becomes a column. Fields you leave out are left out.
* **Prefer facts on public pages.** Websites, addresses, founders, prices, and ratings fill well. Private or paywalled
  data does not.
* **Don't ask for a ranking.** "Top 10" returns 10 matching rows, not the 10 best. Ask for a column such as a rating
  and sort it yourself.

## From the CLI

Install the CLI and sign in:

```bash theme={null}
npm install -g @tiny-fish/cli@latest
tinyfish auth login
```

Build a dataset and wait for its rows:

```bash theme={null}
tinyfish dataset create "Specialty coffee shops in Oakland with their website and rating" --rows 25 --pretty
```

To review the columns first, plan the schema, edit the file, then create from it:

```bash theme={null}
tinyfish dataset plan "Specialty coffee shops in Oakland with their website and rating" > spec.json
tinyfish dataset create --from-spec spec.json --rows 25 --pretty
```

Then read and manage it:

```bash theme={null}
tinyfish dataset list --pretty
tinyfish dataset rows <dataset_id> --all
tinyfish dataset populate <dataset_id> --rows 50
```

`create` and `populate` wait for the run by default. Add `--async` to return right away, then follow the run with
`tinyfish dataset watch <dataset_id> <run_id>`.

## From the API

Create an API key at [agent.tinyfish.ai/api-keys](https://agent.tinyfish.ai/api-keys) and export it:

```bash theme={null}
export TINYFISH_API_KEY="your_api_key_here"
```

The same two-step flow over HTTP. First plan the schema:

```bash theme={null}
curl https://agent.tinyfish.ai/v1/datasets/plan \
  -H "X-API-Key: $TINYFISH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "prompt": "Specialty coffee shops in Oakland with their website and rating" }'
```

Edit the returned `spec` if you need to, then create the dataset from it:

```bash theme={null}
curl https://agent.tinyfish.ai/v1/datasets \
  -H "X-API-Key: $TINYFISH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "spec": { ...the spec from plan... }, "target_rows": 25 }'
```

Follow the run with `GET /v1/datasets/{id}/runs/{run_id}/events`, or check `GET /v1/datasets/{id}` until `status` is
`ready`, `failed`, or `cancelled`. A failed run explains why in `run.error`. Then page through
`GET /v1/datasets/{id}/rows`. See the [reference](https://docs.tinyfish.ai/datasets/reference.md) for every field.

## Read Next

> **[Datasets reference](https://docs.tinyfish.ai/datasets/reference.md)**
>
> Endpoints, the spec format, statuses, events, errors, and limits

> **[CLI setup](https://docs.tinyfish.ai/cli.md)**
>
> Install the CLI and manage your API key


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.