Data Export
Export datasets in multiple formats for use in your applications, analysis tools, or other systems.
Available Formats
| Format | Best For | Content-Type |
|---|---|---|
| JSON | Web applications, APIs | application/json |
| CSV | Spreadsheets, data analysis | text/csv |
| TSV | Tab-separated, easy pasting | text/tab-separated-values |
| XLSX | Excel spreadsheets | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
JSON Export (Default)
JSON is the default format for all dataset queries:
Query dataset with JSON response
curl "https://api.tryopendata.ai/v1/datasets/census/state-populations?limit=5" | jqCSV Export
Request CSV format using the Accept header or format parameter:
# Using Accept headercurl -H "Accept: text/csv" \"https://api.tryopendata.ai/v1/datasets/census/state-populations?limit=100"# Using format parameterGET /v1/datasets/census/state-populations?format=csv&limit=100
state,year,populationCalifornia,2023,39029342Texas,2023,30029572...
Python Example
import pandas as pd# Fetch CSV directly into pandasurl = "https://api.tryopendata.ai/v1/datasets/census/state-populations?format=csv"df = pd.read_csv(url)print(df.head())
TSV Export
Tab-separated values work the same way as CSV:
# Using Accept headercurl -H "Accept: text/tab-separated-values" \"https://api.tryopendata.ai/v1/datasets/census/state-populations?limit=100"# Using format parameterGET /v1/datasets/census/state-populations?format=tsv&limit=100
XLSX Export
Download data as an Excel spreadsheet:
curl -H "Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" \"https://api.tryopendata.ai/v1/datasets/census/state-populations" \-o state-populations.xlsx# Using format parameterGET /v1/datasets/census/state-populations?format=xlsx
Selecting Fields
Export only specific fields to reduce data size:
# JSON with selected fieldsGET /v1/datasets/census/state-populations?fields=state,population&limit=100# CSV with selected fieldsGET /v1/datasets/census/state-populations?fields=state,population&format=csv
Pagination for Large Exports
For datasets larger than the limit allows, paginate through the data:
# Python: Export all data with paginationimport requestsdef export_all(provider, dataset, page_size=1000):all_data = []offset = 0while True:response = requests.get(f"https://api.tryopendata.ai/v1/datasets/{provider}/{dataset}",params={"limit": page_size, "offset": offset})data = response.json()all_data.extend(data["data"])if len(data["data"]) < page_size:breakoffset += page_sizereturn all_datadata = export_all("census", "state-populations")
Downloading Large Results
The API returns a maximum of 1000 rows per request. If a dataset has more rows than that, use the pagination approach shown above to walk through the full result set. CSV format works well for bulk downloads since it keeps the response size compact.
Rate Limits for Exports
Export operations count against your rate limits. For large exports:
- Use pagination with reasonable page sizes (1000-5000 rows)
- Add delays between requests to stay under limits
- Create a free account for higher rate limits
Related
- API Reference - Complete endpoint details
- Rate Limits - Usage quotas
- Quick Start - Getting started guide