# Use a public dataset

Source: https://mostlyright.md/docs/guides/use-public-datasets/

[Datasets](/datasets/) lists every public dataset. A dataset's public page carries its README, tables, freshness, JSON explorer and AI access. Open its chat and ask “How can my app query this table and check for updates?” Chat gives you the table URL, key setup and code for its available operations. In the CLI, run `mr-data public tables DATASET_SLUG` to find the table ID, then `mr-data public api-guide TABLE_ID` for the same examples.

Create a personal `mr_use_…` key under Settings → Access and send it against any public dataset. The first keyed request connects that dataset to the workspace, which lists it under Using and counts it as a use for the publisher. The connection copies nothing and leaves the active workspace alone.

## Choose how to use the data

| Need | What to use |
| --- | --- |
| Inspect a small result | Explore data in the app. Your browser uses your logged-in session and never receives an API key. |
| Ask Claude, Codex, or another agent | Use with AI. Connect the MCP client with OAuth and pick the workspace. |
| Write an application, notebook, or job | Use the API with an `mr_use_…` key. |
| Train a model or refresh a local analytical store | Download the current Parquet file and query it locally with DuckDB, Polars, Pandas, or Arrow. |

An `mr_use_` key belongs to the member who made it and works in one workspace. It reads any public dataset and that workspace's own tables, up to 10,000 rows a query, paged to the end. Past the free sample, its reads count against the key holder's monthly allowance unless the workspace is subscribed. It never reads another workspace's private tables. A dataset the workspace removed under Using comes back on the next key request for it.

`mr_live_…` is the key for the SDK and hosted tables. `mr_cli_…` authorizes a command-line device. Query and Current take only `mr_use_…`.

## Query small results as JSON

The query endpoint returns bounded rows, filters, ordering and aggregates as typed JSON. Each answer names the table version and content digest behind the result.

```bash
curl -sS \
  -H "x-api-key: $MOSTLYRIGHT_USE_KEY" \
  -H "content-type: application/json" \
  -d '{"columns":["city","date","temperature"],"limit":25}' \
  "https://api.mostlyright.md/api/v2/public/tables/$TABLE_ID/query"
```

The query object is closed, and the endpoint runs no arbitrary SQL. A response reports returned rows, scanned bytes, elapsed time, and whether its row limit cut the result.

[Public Dataset API](/docs/reference/public-dataset-api/) carries the request and error contract.

## Download the current Parquet file

Current hands back the complete immutable snapshot.

```bash
curl -sS -o table.parquet \
  -H "x-api-key: $MOSTLYRIGHT_USE_KEY" \
  "https://api.mostlyright.md/api/v2/public/tables/$TABLE_ID/current"
```

Every response carries a strong `ETag` and a SHA-256 content digest. Send that ETag back as `If-None-Match` on the next refresh. A `304` means the file has not changed, and nothing downloads.

```python
import duckdb

rows = duckdb.sql("""
  select city, avg(temperature) as mean_temperature
  from read_parquet('table.parquet')
  group by city
  order by mean_temperature desc
""").fetchall()
```

Do not fetch Current on every inference request. Refresh on a schedule, verify the digest, then replace a local file or DuckDB table atomically. The request path queries that copy with predictable latency.

In the browser, a logged-in reader downloads a table as Parquet or CSV from the dataset page. A CSV file is several times larger than the Parquet one (text-heavy tables expand the most) and is written when you ask for it, so a large table takes longer to arrive. The CSV starts with a UTF-8 byte-order mark so spreadsheets read non-ASCII text correctly. The keyed `/current` endpoint and `mr-data download` return Parquet only.

## Remove access

Removing a dataset from the workspace stops its Current and Query access at once. Revoking a key stops the requests made with it. Disconnecting an AI tool ends its OAuth connection.
