Back to all articles
Tutorial

How to Use ArcGIS REST API Query Parameters

Learn the ArcGIS REST API query parameters that matter most — where, outFields, returnGeometry, f, and more. A practical reference with real examples.

Muhammad Junaid BaigOctober 6, 20269 min read

Every ArcGIS REST FeatureServer exposes a /query endpoint. This is what almost every GIS tool — including ours — uses to fetch features from a service. Understanding how to construct a query is essential if you want to pull exactly the data you need.

This article is a practical reference to the query parameters that matter most.

The basic query URL

The simplest query looks like this:

https://services.arcgis.com/.../FeatureServer/0/query?where=1%3D1&outFields=*&f=json

This asks for every feature in layer 0 with all attributes, returned as JSON. The %3D is a URL-encoded equals sign (=).

The parameters you will use most

where

The attribute filter. Uses SQL syntax. The most common value is 1=1 (return everything).

where=POPULATION > 10000
where=STATE = 'California'
where=YEAR > 2020 AND STATUS = 'Active'

outFields

Which attribute fields to return. Use * for all fields, or a comma-separated list for a subset.

outFields=*
outFields=OBJECTID,NAME,POPULATION

Reducing outFields makes queries significantly faster on large datasets.

returnGeometry

Whether to include geometry. Defaults to true.

returnGeometry=false

Set to false when you only need attributes — this makes the response smaller and faster.

f

The output format. Common values:

  • f=json — ArcGIS JSON format (default)
  • f=geojson — GeoJSON (not all services support this)
  • f=pjson — pretty-printed JSON (for debugging)
  • f=html — HTML (rarely useful)

returnCountOnly

Returns just the count of matching features, without any data. Extremely fast.

returnCountOnly=true

returnIdsOnly

Returns only the object IDs of matching features. Useful for paginated downloads — this is what a browser-based downloader uses under the hood.

returnIdsOnly=true

objectIds

Fetches specific features by their object IDs. Used for retrieving chunks of data.

objectIds=1,2,3,4,5

resultOffset and resultRecordCount

Pagination parameters. Most servers cap a single query at 1,000–2,000 features.

resultOffset=0&resultRecordCount=1000
resultOffset=1000&resultRecordCount=1000

Increment the offset by the record count until you get fewer features back than you requested — that means you have hit the end.

geometry and spatialRelationship

Spatial filter. Return only features that intersect (or touch, or contain, etc.) a given geometry.

geometry=-95.99,36.15,-95.98,36.16&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&inSR=4326

outSR

Output spatial reference. Forces the response geometry to a specific coordinate system.

outSR=4326

orderByFields

Sort the results by one or more fields.

orderByFields=POPULATION DESC

groupByFieldsForStatistics

Used with outStatistics to group features before aggregating.

returnDistinctValues

Returns only unique values for the specified outFields.

outFields=STATE&returnDistinctValues=true

Putting it together: a real example

Suppose you want to get all parcels in a specific county that are larger than 5 acres, sorted by area, in WGS84 coordinates:

https://services.arcgis.com/.../Parcels/FeatureServer/0/query?where=ACRES > 5&outFields=APN,OWNER,ACRES&returnGeometry=true&outSR=4326&orderByFields=ACRES DESC&f=json

Add pagination if you expect more than 1,000 results:

&resultOffset=0&resultRecordCount=1000

Common errors and how to fix them

  • "Invalid URL" — check that you have URL-encoded special characters like spaces (use %20), quotes (use %27), and equals (use %3D).
  • "Field not found" — verify the field name. Field names are case-sensitive on some servers.
  • "Too many features" — add pagination with resultOffset and resultRecordCount.
  • "Token required" — the service is secured. You need an authentication token.
  • Garbled geometry — check the outSR. If the source is in Web Mercator and you expect WGS84, they will not match.

Why you might not need to do this manually

If all you want is to download a dataset, you do not need to build query URLs by hand. A browser-based tool like Geo Server Data Downloader handles the pagination, chunking, and format conversion automatically — and lets you export the result as Shapefile, GeoJSON, KML, or GeoPackage without writing a single query.

Summary

The ArcGIS REST query API is powerful once you know the parameters. For quick one-off queries, use where, outFields, and f=json. For downloads, add returnIdsOnly and pagination. For spatial filters, use geometry and spatialRel. Everything else is icing on the cake.

#ArcGIS#REST API#Query#Developer
Written by Muhammad Junaid Baig, a geospatial developer who builds and maintains Geo Server Data Downloader. About the author. Spotted a mistake or an outdated step? Tell us and we will fix it.

Related guides

Ready to try it yourself?

Export ArcGIS REST services, WFS endpoints, and ArcGIS Online datasets to Shapefile, GeoJSON, KML, or GeoPackage — all in your browser.

Open the Downloader