Query any dataset
query_datasetFilter and pull records from portal dataset layers using SQL conditions and an optional nearby location/radius.
Instructions
Fetch records from any portal dataset layer with a SQL filter, optionally near a place.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| near | No | Optional street address or 'latitude,longitude'; when given, only records within radius_miles of it are returned. | |
| limit | No | Maximum number of records to return. | |
| where | No | SQL where clause over the layer's fields (see describe_dataset), e.g. "ZIP = '28205'" or "DATE_REPORTED >= TIMESTAMP '2026-01-01 00:00:00'". Use '1=1' for everything. | 1=1 |
| fields | No | Fields to return; omit for all. | |
| order_by | No | e.g. 'DATE_REPORTED DESC'. | |
| layer_url | Yes | ArcGIS layer URL from search_datasets, ending in /MapServer/<n> or /FeatureServer/<n>. | |
| radius_miles | No | Used with near. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notes | No | ||
| since | No | Earliest date included (local time). | |
| records | Yes | ||
| location | No | ||
| breakdown | No | Counts of all matching records per value. | |
| breakdown_by | No | ||
| radius_miles | No | ||
| total_matching | Yes | Records matching the filters; may exceed returned. |