query_resource_data for fast querying via the Tabular API, and download_and_parse_resource for direct file downloads.
Choosing the right tool
query_resource_data
Best for:
- CSV and XLSX files
- Files within size limits
- Filtering and sorting
- Quick data previews
- Pagination through results
- CSV files ≤ 100 MB
- XLSX files ≤ 12.5 MB
- Only tabular formats
download_and_parse_resource
Best for:
- JSON and JSONL files
- Large files (>100 MB)
- Files exceeding Tabular API limits
- External URLs
- Full dataset analysis
- Requires full download
- Supports: CSV, CSV.GZ, JSON, JSONL
- Default: 500 MB size limit
Using query_resource_data
Thequery_resource_data tool queries data through the Tabular API without downloading files.
Basic usage
Preview strategy
Always start with a smallpage_size to preview the data structure:
Filtering data
The Tabular API supports six filter operators:exact: Exact match (default)contains: Substring matchless: Less than or equal (≤)greater: Greater than or equal (≥)strictly_less: Strictly less than (<)strictly_greater: Strictly greater than (>)
Filter examples
Filters are applied on the server side by the Tabular API, so you only receive matching rows.
Sorting data
Sort results by any column in ascending or descending order:Pagination
For datasets with many rows, use pagination to retrieve data in chunks:Pagination indicators
The tool provides helpful indicators:- Total rows: Complete row count in the dataset
- Total pages: Number of pages at current page size
- Retrieved: Number of rows in the current page
- Next page hint: Suggestion to continue with
page=N
Combining filters and sorting
You can filter and sort simultaneously:Using download_and_parse_resource
Thedownload_and_parse_resource tool downloads and parses files directly.
Basic usage
Preview strategy
Always start with the defaultmax_rows to preview:
max_rows:
Supported formats
The tool supports:- CSV: Comma-separated values
- CSV.GZ: Compressed CSV files
- JSON: JSON arrays or single objects
- JSONL: Line-delimited JSON (also called NDJSON)
The tool automatically detects file format from the filename and Content-Type header.
CSV delimiter detection
For CSV files, the tool automatically detects the delimiter:- Uses Python’s
csv.Snifferon the first 5 lines - Supports:
,(comma),;(semicolon),\t(tab),|(pipe) - Falls back to counting delimiter occurrences if sniffing fails
Gzip compression
Gzipped files are automatically decompressed:JSON handling
The tool handles multiple JSON formats:- JSON arrays:
[{...}, {...}] - Single objects:
{...}(returned as a one-item list) - JSONL/NDJSON: One JSON object per line
File size limits
You can adjust the maximum download size:Format limitations
- XLSX/XLS: Not supported by this tool. Use
query_resource_datafor Excel files under 12.5 MB. - XML: Format detected but parsing not yet implemented.
- Other formats: Will be reported as unsupported.
Working with large datasets
Small datasets (<500 rows)
Usequery_resource_data with adjusted page size:
Medium datasets (500-1000 rows)
Decide based on your needs:- Specific data: Use
query_resource_datawith filters - Full analysis: Use
download_and_parse_resource
Large datasets (>1000 rows)
For comprehensive analysis:Handling errors
Resource not available via Tabular API
If you get this error withquery_resource_data:
- Exceeds size limits (CSV >100 MB, XLSX >12.5 MB)
- Is not tabular data
- Has an unsupported format
download_and_parse_resource instead.
File too large
max_size_mb parameter:
Format not supported
- For XLSX files: Use
query_resource_dataif under 12.5 MB - For other formats: The file may need manual processing
Output format
Both tools return data in a consistent format:Long values (>100 characters) are automatically truncated with ”…” for readability.
Best practices
- Always preview first: Start with small page sizes or row counts
- Check resource info: Use
get_resource_infoto check Tabular API availability - Use filters: Reduce data volume by filtering on the server side
- Choose the right tool:
- Small tabular data →
query_resource_data - Large files or JSON →
download_and_parse_resource
- Small tabular data →
- Monitor size: Be mindful of file sizes and adjust limits accordingly
Next steps
Working with datasets
Learn how to find and explore datasets
Usage metrics
Check dataset and resource statistics