SQL Sandbox

The Sandbox is a browser-based SQL editor for querying any dataset on OpenData. Write SQL, see results instantly, and save queries as reusable views.

Getting started

The sandbox needs to know which dataset you want to query. You pick one by searching on the sandbox page itself, or by passing a dataset parameter in the URL:

URL format
/sandbox?dataset=provider/dataset

For example, /sandbox?dataset=census/state-populations opens the Census state populations dataset, ready to query.

Finding a dataset slug

Every dataset on OpenData has a two-part identifier: provider/dataset. The provider is the organization that publishes the data (like census, bls, or noaa), and the dataset is the specific table within that provider.

You can find the right slug a few ways:

Search right here

Type a topic below and select a dataset. You'll get the exact slug to use in the sandbox.

Find a dataset slug

Use the search page

The search page lets you browse the full catalog with filters for provider, category, and status. Each dataset card shows the slug in the format provider/dataset.

Use the API

The search endpoint returns dataset metadata including the slug. This is useful if you want to find datasets programmatically.

Search for datasets via API

curl "https://api.tryopendata.ai/v1/search?q=inflation&limit=3" | jq

Each result includes provider and slug fields. Combine them as provider/slug to get your dataset identifier.

Writing SQL

Once you've loaded a dataset, the sandbox generates a starter query that selects a few columns. You can edit this freely. Your data is available as a table called data, or you can use the qualified name in double quotes:

Both of these work
-- Short form
SELECT * FROM data WHERE year >= 2020
-- Qualified form
SELECT * FROM "census/state-populations" WHERE year >= 2020

Click any column name in the schema sidebar to insert it at your cursor. The “How do I...” section has templates for common patterns like aggregations, window functions, and date filtering.

Keyboard shortcut
Press Cmd+Enter (or Ctrl+Enter on Windows) to run your query. No need to reach for the Run button.

For a full reference on supported SQL syntax, functions, and limitations, see the SQL Query documentation.

Builder mode

If you'd rather not write SQL, switch to Builder mode using the toggle in the toolbar. Builder gives you a point-and-click interface for filtering, sorting, selecting columns, and aggregating data. It generates the same query under the hood.

On mobile devices, the sandbox defaults to Builder mode since the SQL editor isn't practical on small screens.

Cross-dataset queries

You can query multiple datasets in a single SQL statement by using their qualified names. Open the sandbox without a dataset parameter and reference tables directly:

Joining two datasets
SELECT
pop.state,
pop.population,
cpi.value AS price_index
FROM "census/state-populations" pop
JOIN "bls/cpi-u" cpi
ON pop.year = cpi.year
WHERE pop.year = 2023
LIMIT 20
Authentication required
Cross-dataset queries and SQL queries in general require an API key or an active session. Get one here.

Saving as a view

Once your query returns results, hit Save (or Cmd+S) to open the save dialog. Give your view a Name (the slug in its URL auto-derives from it), tweak the Slug if you want, and add an optional Description.

The publish toggle controls visibility: left off it saves as a draft only you can see while you iterate, and flipped on it publishes at 1.0.0 and lands on your public profile.

A published view gets its own URL at /@username/views/slug (and a versioned API endpoint), so you can share your curated slice of the data with anyone. The same dialog also handles editing your drafts and forking someone else's view into a copy under your profile.

For the full story on drafts, versioning, forking, and cross-dataset SQL views, see the Views documentation.

URL parameters

The sandbox reads its state from the URL, so you can bookmark or share exact configurations:

ParameterDescriptionExample
datasetDataset to loadcensus/state-populations
modesql or buildersql
viewLoad a saved view by nametop-states-2023
autorunRun the query immediately on load1

Next steps

  • SQL Query reference for the full syntax, allowed functions, and limits
  • Views to learn about saving and sharing query results
  • Querying guide for filtering, sorting, and aggregation via the REST API

Search datasets

Search for datasets or run quick actions