Query (Feature Service/Layer)

Description

The query operation is performed on a feature service layer resource. The result of this operation is either a feature set or an array of feature IDs (if returnIdsOnly is set to true) and/or a result extent (if returnExtentOnly is set to true).

While there is a limit to the number of features included in the feature set response, there is no limit to the number of object IDs returned in the ID array response. Clients can exploit this to get all the query conforming object IDs by specifying returnIdsOnly=true and subsequently requesting feature sets for subsets of object IDs.

In the feature set response, the layer features include their geometries. The records for tables do not.

NoteNote:

If the query results include an empty feature set, the fields set is not returned.

NoteNote:

Line and polygon layers in a hosted feature service from a spatiotemporal data store in ArcGIS Enterprise may have a spatial index precision of more than 50 Meters. Line and polygon layers generated from the GeoAnalytics Server are created this way for example. In these cases, query with a geometry and outStatistics or a geometry and returnDistinctValues will return results that are approximates / estimates from a wider sample. Exact statistics/values require using the filter, querying the features into the client and computing the exact statistics/values.

NoteNote:

Approximate outStatistics results will also be returned for layers in a hosted feature service from a spatiotemporal data store when the spatial relation is other than intersects or contains.

NoteNote:

Query with returnDistinctResults defaults to using spatial relation intersects irrespective of a user selected spatial relation.

For time-aware layers, you can use the time parameter to specify the time instant or the time extent to query.

You can provide arguments to the query operation defined in the following parameters table:

To use pagination with aggregated queries (queries using either returnDistinctValues, or outStatistics with groupByFieldsForStatistics) on hosted feature services in ArcGIS Enterprise, the supportsPaginationOnAggregatedQueries property must be true on the layer. Hosted feature services using a spatiotemporal data store do not currently support pagination on aggregated queries.

New in 10.7

New in 10.6.1

NoteNote:

For feature services published to an ArcGIS Enterprise federated server with data stored in a registered enterprise geodatabase, when requesting quantized geometry, if returnTrueCurves = true the curves will be densified in the quantized results.

New in 10.5

New in 10.3.1

NoteNote:
  • When not using the resultOffset and resultRecordCount parameters, the exceededTransferLimit property may also be included in the query results. In this case, the property will be true only if the number of records exceeds the maximum number configured by the server administrator.
  • In some cases when using the resultOffset and resultRecordCount parameters, the exceededTransferLimit property may be included in the query results even though the value specified in the resultRecordCount has not been exceeded. This is due to internal spatial index filtering of the query results. For this reason you should always rely on the exceededTransferLimit property to determine if you should page through results rather than relying on the number of results returned from each page. In some extreme cases zero results can be returned but the exceededTransferLimit property will be returned. In these cases you should continue paging though your results until exceededTransferLimit is no longer returned.
  • If using orderByFields with the resultOffset and resultRecordCount parameters to paginate through an ordered set of rows, make sure to set the orderByFields such that order is deterministic. For example, if you need to order by type and multiple rows can have the same type values, set the orderByFields to be type,objectid.

New in 10.3

Request parameters

Parameter

Details

f

Description: The response format. The default response format is html.

Values: html | json | geojson (default, when returnIdsOnly=false and returnCountOnly=false)

Values: html | json | geojson (when returnIdsOnly=true or returnCountOnly=true)

Values: html | json | geojson | pbf (protocol buffer (pbf) is only supported when the supportedQueryFormat property on the layer includes pbf)

where

Description: A WHERE clause for the query filter.

SQL 92 WHERE clause syntax on the fields in the layer is supported for most data sources. Some data sources have restrictions on what is supported. Hosted feature services in ArcGIS Enterprise running on a spatiotemporal data source have restrictions on what is supported; they only support a subset of SQL 92. For example, spatiotemporal based feature services support the like operator but do not support the not like operator or field equivalency expressions like field1 = field2. Here is a list of supported SQL 92 with spatiotemporal based feature services:

( '<=' | '>=' | '<' | '>' | '=' | '!=' | '<>' | LIKE )

(AND | OR)

(IS | IS_NOT)

(IN | NOT_IN) ( '(' ( expr ( ',' expr )* )? ')' )

COLUMN_NAME BETWEEN LITERAL_VALUE AND LITERAL_VALUE

Examples:

where=POP2000 > 350000

where=CITY_NAME = 'Barrington'

If you are working with ArcGIS Server 10.4 or later, the dateFieldsTimeReference property of the feature service identifies the time zone that all dates are stored in. If you are querying a date type field and have dateFieldsTimeReference set to a specific time zone, make sure your WHERE clause issues the time in that specific time zone. For example, if you want to return all the records that match 1:00 p.m. on February 9, 2015, Pacific standard time, your WHERE clause would be as follows:

where=pacific_time_date_field = DATE '2015-02-09 13:00:00'

Although you issue local time in your WHERE clause, Query always returns date values in UTC. You can set the dateFieldsTimezoneID property in the ArcMap Service Editor Parameters tab, when you publish the service. If you don't have dateFieldsTimezoneID set, be sure your WHERE clause issues the time you are querying in UTC. The dateFieldsTimezoneID property does not apply to fields that were time enabled through the Layer Properties Time tab in ArcMap at the time of publishing.

10.6.1 or later the INTERVAL syntax can be used in place of the date-time queries and will be standardized across all map and feature services. There are two specific ways to use the INTERVAL syntax.

For use with INTERVAL there are two main formats for date and timestamp:

<DateField> >= CURRENT_DATE -+ INTERVAL '<IntervalValue>' <TimeStampFormat>

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL '<IntervalValue>' <TimeStampFormat>

You aren't limited to just DAY when using INTERVAL. Here are some of the other formats you can use:

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD' DAY

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH' HOUR

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'MI' MINUTE

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'SS(.FFF)' SECOND

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH' DAY TO HOUR

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH:MI' DTY TO MINUTE

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH:MI:SS(.FFF)' DAY TO SECOND

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH:MI' HOUR TO MINUTE

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH:SS(.FFF)' HOUR TO SECOND

<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'MI:SS(.FFF)' MINUTE TO SECOND

NoteNote:
  • Except for the second (.FFF) value (which can be a decimal value), all values must be integers.
  • These query formats can be used with CURRENT_DATE in place of CURRENT_TIMESTAMP, and can be used with + or - INTERVAL values.
  • If a date field is specified in the outFields list, the date-time will always be returned in formatted UTC.
  • In 10.6.1, CURRENT_TIMESTAMP will return the date and time in the time zone of the back-end geodatabase for ArcGIS Enterprise hosted feature services. This means that you may get inconsistent results when querying hosted feature services, as all values are stored in UTC.

Examples:

https://services.myserver.com/OrgID/arcgis/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?where=date_time > CURRENT_TIMESTAMP - INTERVAL '1' DAY&returnGeometry=false&returnCountOnly=true&resultType=&f=pjson

https://services.myserver.com/OrgID/arcgis/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?where=date_time > CURRENT_TIMESTAMP - INTERVAL '1' DAY&returnGeometry=false&returnCountOnly=true&resultType=&f=pjson
https://services.myserver.com/OrgID/arcgis/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?where=date_time > CURRENT_TIMESTAMP + INTERVAL '1 04' DAY TO HOUR&returnGeometry=false&returnCountOnly=true&resultType=&f=pjson

objectIds

The object IDs of this layer or table to be queried.

NoteNote:

There might be a drop in performance if the layer/table data source resides in an enterprise geodatabase and more than 1,000 objectIds are specified.

Syntax: objectIds=<objectId1>, <objectId2>

Example: objectIds=37, 462

geometry

Description: The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API. In addition to the JSON structures, you can specify the geometry of envelopes and points with a simple comma-separated syntax.

Syntax:

  • JSON structures: geometryType=<geometryType>&geometry={geometry}
  • Envelope simple syntax: geometryType=esriGeometryEnvelope&geometry=<xmin>,<ymin>,<xmax>,<ymax>
  • Point simple syntax: geometryType=esriGeometryPoint&geometry=<x>,<y>

Examples:

  • geometryType=esriGeometryEnvelope&geometry={xmin: -104, ymin: 35.6, xmax: -94.32, ymax: 41}
  • geometryType=esriGeometryEnvelope&geometry=-104,35.6,-94.32,41
  • geometryType=esriGeometryPoint&geometry=-104,35.6

geometryType

Description: The type of geometry specified by the geometry parameter. The geometry type can be an envelope, a point, a line, or a polygon. The default geometry type is an envelope.

Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

inSR

Description: The spatial reference of the input geometry.

The spatial reference can be specified as either a well-known ID or as a spatial reference JSON object.

If the inSR is not specified, the geometry is assumed to be in the spatial reference of the map.

spatialRel

Description: The spatial relationship to be applied to the input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is intersects (esriSpatialRelIntersects).

Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

relationParam

Description: The spatial relate function that can be applied while performing the query operation. An example for this spatial relate function is "FFFTTT***".

For more information on this spatial relate function, see the documentation for the spatial relate function.

NoteNote:

This parameter is not supported in the ArcGIS Online hosted service case.

time

Description: The time instant or the time extent to query.

Time instant

Syntax: time=<timeInstant>

Example: time=1199145600000 (1 Jan 2008 00:00:00 GMT)

Time extent

Syntax: time=<startTime>, <endTime>

Example: time=1199145600000, 1230768000000 (1 Jan 2008 00:00:00 GMT to 1 Jan 2009 00:00:00 GMT)

A null value specified for start time or end time will represent infinity for start or end time, respectively. Example: time=null, 1230768000000

distance

Description: The buffer distance for the input geometries. The distance unit is specified by units. For example, if the distance is 100, the query geometry is a point, units is set to meters, and all points within 100 meters of the point are returned.

Syntax: distance=<distance>

Example: distance=100

The geodesic buffer is created based on the datum of the output spatial reference if it exists. If there is no output spatial reference, the input geometry spatial reference is used. Otherwise, the native layer spatial reference is used to generate the geometry buffer used in the query.

This parameter only applies if supportsQueryWithDistance is true.

units

Description: The unit for calculating the buffer distance. If unit is not specified, the unit is derived from the geometry spatial reference. If the geometry spatial reference is not specified, the unit is derived from the feature service data spatial reference.

This parameter only applies if supportsQueryWithDistance is true.

Values: esriSRUnit_Meter | esriSRUnit_StatuteMile | esriSRUnit_Foot | esriSRUnit_Kilometer | esriSRUnit_NauticalMile | esriSRUnit_USNauticalMile

outFields

Description: The list of fields to be included in the returned result set. This list is a comma delimited list of field names.

You can also specify the wildcard "*" as the value of this parameter. In this case, the query results include all the field values.

Example: outFields=AREANAME,ST,POP2000

Example (wildcard usage): outFields=*

returnGeometry

This option was added at 10.1.

Description: If true, the result includes the geometry associated with each feature returned. The default is true.

Values: true | false

maxAllowableOffset

This option was added at 10.1.

Description: This option can be used to specify the maxAllowableOffset to be used for generalizing geometries returned by the query operation.

The maxAllowableOffset is in the units of outSR. If outSR is not specified, maxAllowableOffset is assumed to be in the unit of the spatial reference of the map.

Example: maxAllowableOffset=2

geometryPrecision

This option was added at 10.1.

Description: This option can be used to specify the number of decimal places in the response geometries returned by the Query operation.

This applies to X and Y values only (not m or z-values).

Example: geometryPrecision=3

outSR

Description: The spatial reference of the returned geometry.

The spatial reference can be specified as either a well-known ID or as a spatial reference JSON object.

If outSR is not specified, the geometry is returned in the spatial reference of the map.

When using outSR with pbf, the pbf format will use coordinate quantization for layer queries. When an output spatial reference is not provided for a query operation, the Feature Service derives coordinate quantization parameters from the layer’s spatial reference. If the precision in the layer’s spatial reference is inadequate for the client application’s use, it should pass in a spatial reference with suitable precision as the output spatial reference. If the layer’s source spatial reference has the desired precision and it is suitable for the client’s use, the client can use the source layer's spatial reference as the output spatial reference.

havingClause

This option was added at 10.6.1

Description: This option is a condition used with outStatistics that limits the query result to groups which satisfy the aggregation function used. The havingClause parameter is used with the groupBy and outStatistics parameters and allows you to filter results from outStatistics. This parameter applies only if the supportsHavingClause property of the layer is true.

Values: AVG | COUNT | SUM | STDDEV | MIN | MAX | VAR

Example: AVG(population) > 1000000

The havingClause parameter takes aggregate functions such as AVG(<fieldname>). It does not support the outStatisticFieldName from the outStatistics parameter. For example, for outStatistics=[{"statisticType":"AVG","onStatisticField":"housing_price","outStatisticFieldName":"avgHousePrice"}], the having clause can't be set to avgHousePrice > 1000. It must be set as AVG(housing_price) > 1000.

Also, you can use statistics functions in the having clause that are not necessarily in the outStatistics parameter. The example below returns the average housing price for neighborhoods where there are more than 1000 homes.

Example: outStatistics=[{"statisticType":"AVG","onStatisticField":"housing_price","outStatisticFieldName":"avgHousePrice"}], havingClause=COUNT(houses) > 1000

NoteNote:

havingClause must be used with groupBy and outStatistics.

gdbVersion

This option was added at 10.1.

Description: The geodatabase version to query. This parameter applies only if the isDataVersioned property of the layer is true. If this is not specified, the query will apply to the published map’s version.

Syntax: gdbVersion=<version>

Example: gdbVersion=SDE.DEFAULT

returnDistinctValues

Description: If true, it returns distinct values based on the fields specified in outFields. This parameter applies only if the supportsAdvancedQueries property of the layer is true. This parameter can be used with returnCountOnly to return the count of distinct values of subfields.

Values: <true | false>

Example: returnDistinctValues=true

NoteNote:

Make sure to set returnGeometry = false when returnDistinctValues = true or results will not be reliable.

returnIdsOnly

Description: If true, the response only includes an array of object IDs. Otherwise, the response is a feature set. The default is false.

While there is a limit to the number of features included in the feature set response, there is no limit to the number of object IDs returned in the ID array response. Clients can exploit this to get all the query conforming object IDs by specifying returnIdsOnly=true and subsequently requesting feature sets for subsets of object IDs.

When objectIds are specified, setting this parameter to true is invalid.

Values: true | false

returnCountOnly

This option was added at 10.0 SP1.

Description: If true, the response only includes the count (number of features/records) that would be returned by a query. Otherwise, the response is a feature set. The default is false. This option supersedes the returnIdsOnly parameter. If returnCountOnly = true, the response will return both the count and the extent. This parameter can be used with returnDistinctValues to return the count of distinct values of subfields.

Values: true | false

returnExtentOnly

This option was added at 10.3.

NoteNote:

At 10.3, this option is only available for hosted feature services. At 10.3.1, this option is available for hosted and non-hosted feature services.

Description: If true, the response only includes the extent of the features that would be returned by the query. If returnCountOnly=true, the response will return both the count and the extent. The default is false. This parameter applies only if the supportsReturningQueryExtent property of the layer is true.

Values: true | false

orderByFields

This option was added at 10.1.

Description: One or more field names on which the features/records need to be ordered. Use ASC or DESC for ascending or descending, respectively, following every field to control the ordering.

NoteNote:

  • orderByFields is supported on only those layers/tables that indicate supportsAdvancedQueries is true.
  • orderByFields defaults to ASC (ascending order) if <ORDER> is unspecified.

Syntax: orderByFields=field1 <ORDER>, field2 <ORDER>, field3 <ORDER>

Example: orderByFields=STATE_NAME ASC, RACE DESC, GENDER

groupByFieldsForStatistics

This option was added at 10.1.

Description: One or more field names on which the values need to be grouped for calculating the statistics.

NoteNote:

groupByFieldsForStatistics is valid only when the outStatistics parameter is used.

Syntax: groupByFieldsForStatistics=field1, field2

Example: groupByFieldsForStatistics=STATE_NAME, GENDER

outStatistics

This option was added at 10.1.

Description: The definitions for one or more field-based statistics to be calculated.

NoteNote:

  • outStatistics is supported on only those layers/tables that indicate supportsStatistics is true.
  • If outStatisticFieldName is empty or missing, the map server assigns a field name to the returned statistic field. A valid field name can only contain alphanumeric characters and an underscore. If the outStatisticFieldName is a reserved keyword of the underlying DBMS, the operation can fail. Try specifying an alternative outStatisticFieldName.
  • When using outStatistics, the only other parameters that can be used are groupByFieldsForStatistics, orderByFields, time, and where.

Values: An array of statistic definitions. A statistic definition specifies the type of statistic, the field on which it is to be calculated, and the resulting output field name.

Syntax:

[
  {
    "statisticType": "<count | sum | min | max | avg | stddev | var>",
    "onStatisticField": "Field1", 
    "outStatisticFieldName": "Out_Field_Name1"
  },
  {
    "statisticType": "<count | sum | min | max | avg | stddev | var>",
    "onStatisticField": "Field2",
    "outStatisticFieldName": "Out_Field_Name2"
  }  
]

Example:

[
  {
    "statisticType": "sum",
    "onStatisticField": "GENDER",
    "outStatisticFieldName": "PopulationByGender"
  },
  {
    "statisticType": "avg",
    "onStatisticField": "INCOME",
    "outStatisticFieldName": "AverageIncome"
  }
]

returnZ

This option was added at 10.1.

Description: If true, Z values are included in the results if the features have Z values. Otherwise, Z values are not returned. The default is false.

This parameter only applies if returnGeometry is true, and the layer's hasZ property is true.

returnM

This option was added at 10.1.

Description: If true, M values are included in the results if the features have M values. Otherwise, M values are not returned. The default is false.

This parameter only applies if returnGeometry is true, and the layer's hasM property is true .

multipatchOption

Description: This option dictates how the geometry of a multipatch feature will be returned.

Values: <xyFootprint | stripMaterials | embedMaterials | externalizeTextures>

This parameter only applies if the layer's geometryType property is esriGeometryMultiPatch.

If multipatchOption = xyFootprint, the x,y footprint of each multipatch geometry will be returned in the result.

If multipatchOption = stripMaterials, the multipatch geometry will be returned without materials (i.e. colors and textures).

If multipatchOption = embedMaterials, the multipatch geometry will be returned with materials embedded in it.

If multipatchOption = externalizeTextures, the multipatch geometry will be returned with materials, but the textures will be returned by reference.

NoteNote:

If returnGeometry = false, specifying the multipatchOption is not required.

resultOffset

This option was added at 10.3.

Description: This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, resultOffset + 1th). The default is 0.

This parameter only applies if supportsPagination is true.

You can use this option to fetch records that are beyond maxRecordCount.

For example, if maxRecordCount is 1000, you can get the next 100 records by setting resultOffset=1000 and resultRecordCount = 100, so the query results will return the results in the range of 1001 to 1100.

resultRecordCount

This option was added at 10.3.

Description: This option can be used for fetching query results up to the resultRecordCount specified. When resultOffset is specified but this parameter is not, the map service defaults it to maxRecordCount. The maximum value for this parameter is the value of the layer's maxRecordCount property.

This parameter only applies if supportsPagination is true.

Example: resultRecordCount=10 to fetch up to 10 records

quantizationParameters

This option is supported by all feature services in ArcGIS Enterprise at 10.6.1.

Description: Used to project the geometry onto a virtual grid, likely representing pixels on the screen.

NoteNote:
  • This parameter only applies if supportsCoordinatesQuantization is true.

extent

An extent defining the quantization grid bounds. Its SpatialReference matches the input geometry spatial reference if one is specified for the query. Otherwise, the extent will be in the layer's spatial reference.

mode

Geometry coordinates are optimized for viewing and displaying of data.

Value: view

originPosition

Integer coordinates will be returned relative to the origin position defined by this property value.

NoteNote:
Default is upperLeft origin position.

Values: upperLeft | lowerLeft

tolerance

The tolerance is the size of one pixel in the outSpatialReference units, this number is used to convert the coordinates to integers by building a grid with resolution matching the tolerance. Each coordinate is then snapped to one pixel on the grid. Consecutive coordinates snapped to the same pixel are removed to reduce the overall response size.

The units of tolerance are defined by outSpatialReference. If the outSpatialReference is not specified, then tolerance is assumed to be in the unit of the spatial reference of the layer.

If the tolerance is not specified, the maxAllowableOffset is used.

NoteNote:
If the tolerance and maxAllowableOffset are not specified, a default 10,000 x 10,000 grid is used.

Examples

Example 1:

{"mode":"view","originPosition":"upperLeft","tolerance":1.0583354500042335,"extent":{"type":"extent","xmin":-18341377.47954369,"ymin":2979920.6113554947,"xmax":-7546517.393554582,"ymax":11203512.89298139,"spatialReference":{"wkid":102100,"latestWkid":3857}}}

Example 2:

https://services.myserver.com/<tenant>/ArcGIS/rest/services/USAShapeFoldersDec5/FeatureServer/2/query?f=html&where=1=1&returnGeometry=true&spatialRel=esriSpatialRelIntersects&outFields=*&outSR=102100&resultOffset=0&resultRecordCount=2000&quantizationParameters={"mode":"view","originPosition":"upperLeft","tolerance":1.0583354500042335,"extent":{"type":"extent","xmin":-19838806.04126036,"ymin":2146082.189218864,"xmax":-7455049.448307296,"ymax":11542768.51809405,"spatialReference":{"wkid":102100,"latestWkid":3857}}}

Example 3:

{"mode":"view","originPosition":"lowerLeft","tolerance":1.0583354500042335,"extent":{"type":"extent","xmin":-18341377.47954369,"ymin":2979920.6113554947,"xmax":-7546517.393554582,"ymax":11203512.89298139,"spatialReference":{"wkid":102100,"latestWkid":3857}}}

Example 4:

https://services.myserver.com/<tenant>/ArcGIS/rest/services/USAShapeFoldersDec5/FeatureServer/1/query?where=1=1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&maxAllowableOffset=1.0583354500042335&geometryPrecision=&outSR=102100&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=0&resultRecordCount=2000&returnZ=false&returnM=false&quantizationParameters={"mode":"view","originPosition":"lowerLeft","tolerance":1.0583354500042335,"extent":{"type":"extent","xmin":-18341377.47954369,"ymin":2979920.6113554947,"xmax":-7546517.393554582,"ymax":11203512.89298139,"spatialReference":{"wkid":102100,"latestWkid":3857}}}&f=html&token=

returnCentroid

(Optional)

Description: Used to return the geometry centroid associated with each feature returned. If true, the result includes the geometry centroid. The default is false.

Values: true | false

NoteNote:
  • This parameter is only supported on layer query and not service query.
  • The returnCentroid parameter is currently only supported for polygon data.
  • The returnCentroid parameter is ignored for count and object ID queries.
  • The layer metadata returns supportReturningGeometryCentroid in the advancedQueryCapabilities metadata object.
  • The absence of the supportReturningGeometryCentroid property means that the server does not support the returnCentriod parameter.
  • Line and points data will return supportReturningGeometryCentriod = false.

Examples

returnCentroid

Example 1: (When returnGeometry=true and returnCentroid=true)

https://services.myserver.com/OrgID/ArcGIS/rest/services/USAStatesRiversCapitals/FeatureServer/2/query?where=1=1&objectIds=&uniqueIds=&time=&geometry=&geometryType=esriGeometryEnvelope&geohash=&inSR=&spatialRel=esriSpatialRelIntersects &distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&returnCentroid=true&maxAllowableOffset=&geometryPrecision=&outSR=& returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=& groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false& quantizationParameters=&f=html&token=

Example 2: (When returnGeometry=false and returnCentroid=true)

https://services.myserver.com/OrgID/ArcGIS/rest/services/USAStatesRiversCapitals/FeatureServer/2/query?where=1=1&objectIds=&uniqueIds=&time=&geometry=&geometryType=esriGeometryEnvelope&geohash=&inSR=&spatialRel=esriSpatialRelIntersects &distance=&units=esriSRUnit_Meter&outFields=*&returnGeometry=false&returnCentroid=true&maxAllowableOffset=&geometryPrecision=&outSR=& returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=& groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false& quantizationParameters=&f=html& token=
resultType

(Optional)

Description: The resultType parameter can be used to control the number of features returned by the query operation.

Values: none | standard | tile

NoteNote:
  • Support for the resultType parameter is advertised on the layer metadata. For example {"supportQueryWithResultType": true/false}.
  • The maxTileRecordCount and maxStandardRecordCount are server managed (determined by the server). The feature service assigns the max record count relevant to the resultType query parameter.
    • If no resultType query parameter is used then the default maxRecordCount is always used. This can be the default server assigned maxRecordCount (1000, 2000) or an overwritten value provided by the service owner/admin.
    • The resultType=tile is used when the client is using virtual tiling scheme when querying features. Virtual tiling scheme works similar to tiles in a tiled map service layer.
    • The resultType=standard is used with a non-tiled query where the client will send only one query for the full extent.
  • Server advertises max record counts with the layer metadata. For example for points data we return the following max record count:
    • Ex: {'maxRecordCount" : 2000, "tileMaxRecordCount" : 8000, "standardMaxRecordCount" : 32000}.
  • The values of the max record counts might vary based on the type of the data (polygon, point, polyline, table).
  • Pagination queries also support resultType query parameter.
    • If the resultType is specified and the resultRecordCount is not specified with the resultOffset, the server will determine the maxRecordCount relevant to the resultType query parameter.
    • The client can supply the resultRecordCount parameter in the request. This cannot be greater than the standard/tile maxRecordCount value if resultType is used.
  • The layer metadata includes maxRecordCountFactor that can be configured from the admin API. The server maxRecordCountFactor for the tileMaxRecordCount and standardMaxRecordCount is used as a multiplier for the server base value.
    • All maxRecordCount values are adjusted with the maxRecordCountFactor.

Examples

Example 1: (When resultType=none)

The default maxRecordCount is always used. This can be the default server assigned ("maxRecordCount" : 2000) or an overwritten value by the service owner/admin.

https://services.myserver.com/OrgID/ArcGIS/rest/services/USAStatesRiversCapitals/FeatureServer/2/query?where=1=1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=
&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&multipatchOption=&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false
&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=
&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=html&token=

Example 2: (When resultType=standard)

The standardMaxRecordCount is always used. Ex: ("standardMaxRecordCount" : 32000) for point and table layer.

https://services.myserver.com/OrgID/ArcGIS/rest/services/USAStatesRiversCapitals/FeatureServer/2/query?where=1=1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=standard&distance=
&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&multipatchOption=&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false
&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=
&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=html&token=

Example 3: (When resultType=tile)

The tileMaxRecordCount is always used. Ex: ('tileMaxRecordCount" : 8000) for point layer.

https://services.myserver.com/OrgID/ArcGIS/rest/services/USAStatesRiversCapitals/FeatureServer/2/query?where=1=1&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=tile&distance=
&units=esriSRUnit_Meter&outFields=*&returnGeometry=true&multipatchOption=&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false
&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=
&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=html&token=
historicMoment

This option was added at 10.5 and works with ArcGIS Server services only.

Description: The historic moment to query. This parameter applies only if the layer is archiving enabled and the supportsQueryWithHistoricMoment property is set to true. This property is provided in the layer resource.

If historicMoment is not specified, the query will apply to the current features.

Syntax: historicMoment=<Epoch time in milliseconds>

Example: historicMoment=1199145600000

returnTrueCurves

This option was added at 10.5.

Description: Optional parameter which is false by default.

When set to true, returns true curves in output geometries.

When set to false, curves are converted to densified polylines or polygons.

Values: true|false

Example: trueCurveClient=true

NoteNote:

For feature services published to an ArcGIS Enterprise federated server with data stored in a registered enterprise geodatabase, when requesting quantized geometry, if returnTrueCurves = true the curves will be densified in the quantized results.

sqlFormat

Description: The sqlFormat parameter can be either standard SQL92 standard or it can use the native SQL of the underlying data store native. The default is none which means the sqlFormat depends on useStandardizedQuery parameter.

Values: none | standard | native

NoteNote:
  • The SQL format native is supported when useStandardizedQuery=false.

The table summarizes the sqlFormat parameter and what you would expect from the query API.

useStandardizedQuery=true

useStandardizedQeury=false

standard (sql'92)

native (native DBMS sql)

x(not supported)

[none]

Only sql'92 (means standard)

Only DBMS native SQL (native)

Example: sqlFormat=standard

returnExceededLimitFeatures

As of 10.6.1, this option is supported by most feature services, except for feature services published using a spatiotemporal data store.

Description: Optional parameter which is true by default.

When set to true, features are returned even when the results include "exceededTransferLimit": true.

When set to false and querying with resultType = tile features are not returned when the results include "exceededTransferLimit": true. This allows a client to find the resolution in which the transfer limit is no longer exceeded without making multiple calls.

Values: true|false

Example: returnExceededLimitFeatures=false

Example usage

Example 1: Query using a WHERE clause:

https://services.myserver.com/OrgID/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/FeatureServer/0/query?where=magnitude+%3E+4.5&outFields=*&returnGeometry=true&returnIdsOnly=false&f=html

Exapmle 2: Query a table using a WHERE clause and return OBJECTIDs only:

https://services.myserver.com/OrgID/ArcGIS/rest/services/SanFrancisco/311Incidents/FeatureServer/1/query?where=agree_with_incident+%3D+1&returnGeometry=true&returnIdsOnly=true&f=html

Example 3: Page through a query result using resultOffset and resultRecordCount to get the next set of results.Requesting to skip the first 5 records and return the next 10 counties in California ordered by population:

https://services.myserver.com/OrgID/ArcGIS/rest/services/USA/MapServer/3/query?where=STATE_NAME='California'&outFields=Name,Population&returnGeometry=false&resultOffset=5&resultRecordCount=10&orderByFields=Population&f=pjson

JSON Response syntax

When returnIDsOnly=false and returnCountOnly=false

{
  "objectIdFieldName" : "<objectIdFieldName>",
  "globalIdFieldName" : "<globalIdFieldName>",
  "geometryType" : "<geometryType>", //for feature layers only
  "spatialReference" : <spatialReference>, //for feature layers only
  "hasZ" : <true|false>, //added in 10.1
  "hasM" : <true|false>, //added in 10.1
  "fields" : [
    {"name" : "<fieldName1>", "type" : "<fieldType1>", "alias" : "<fieldAlias1>", "length" : "<length1>"},
    {"name" : "<fieldName2>", "type" : "<fieldType2>", "alias" : "<fieldAlias2>", "length" : "<length2>"}
  ],
  "features" : [ //features will include geometry for feature layers only
  <feature1>, <feature2> 
  ]
}

JSON Response syntax

When returnCountOnly=true

{
  "count" : <count>
}

JSON Response syntax

When returnCountOnly=true and returnExtentOnly=true

{
  "count" : <count>, 
  "extent" : <envelope>
}

JSON Response syntax

When returnIdsOnly=true

{
  "objectIdFieldName" : "<objectIdFieldName>",
  "objectIds" : [ <objectId1>, <objectId2> ]
}

JSON Response example

When returnIdsOnly=false and returnCountOnly=false

{
  "objectIdFieldName" : "objectid",
  "globalIdFieldName" : "",
  "geometryType" : "esriGeometryPoint",
  "spatialReference" : {
    "wkid" : 4326
  },
    "fields" : [
    {
      "name" : "objectid", 
      "type" : "esriFieldTypeOID", 
      "alias" : "Object ID"
    }, 
    {
      "name" : "datetime", 
      "type" : "esriFieldTypeDate", 
      "alias" : "Earthquake Date",
      "length" : 36
    }, 
    {
      "name" : "depth", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Depth"
    }, 
    {
      "name" : "eqid", 
      "type" : "esriFieldTypeString", 
      "alias" : "Earthquake ID",
      "length" : 50
    }, 
    {
      "name" : "latitude", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Latitude"
    }, 
    {
      "name" : "longitude", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Longitude"
    }, 
    {
      "name" : "magnitude", 
      "type" : "esriFieldTypeDouble", 
      "alias" : "Magnitude"
    }, 
    {
      "name" : "numstations", 
      "type" : "esriFieldTypeInteger", 
      "alias" : "Number of Stations"
    }, 
    {
      "name" : "region", 
      "type" : "esriFieldTypeString", 
      "alias" : "Region", 
      "length" : 200
    }, 
    {
      "name" : "source", 
      "type" : "esriFieldTypeString", 
      "alias" : "Source", 
      "length" : 50
    }, 
    {
      "name" : "version", 
      "type" : "esriFieldTypeString", 
      "alias" : "Version",
      "length" : 50
    }
  ],
  "features" : [
    {
      "geometry" : {
        "x" : -178.24479999999991,
        "y" : 50.012500000000045
      },
      "attributes" : {
        "objectid" : 3745682,
        "datetime" : 1272210710000,
        "depth" : 31.100000000000001,
        "eqid" : "2010vma5",
        "latitude" : 50.012500000000003,
        "longitude" : -178.2448,
        "magnitude" : 4.7999999999999998,
        "numstations" : 112,
        "region" : "Andreanof Islands, Aleutian Islands, Alaska",
        "source" : "us",
        "version" : "Q"
      }
    },
    {
      "geometry" : {
        "x" : -72.865099999999927,
        "y" : -37.486599999999953
      },
      "attributes" : {
        "objectid" : 3745685,
        "datetime" : 1272210142999,
        "depth" : 40.600000000000001,
        "eqid" : "2010vma4",
        "latitude" : -37.486600000000003,
        "longitude" : -72.865099999999998,
        "magnitude" : 4.9000000000000004,
        "numstations" : 58,
        "region" : "Bio-Bio, Chile",
        "source" : "us",
        "version" : "7"
      }
    }
  ]
}

JSON Response example

When returnIdsOnly=false, returnCountOnly=false, and outFields=""

{
  "objectIdFieldName" : "objectid",
  "globalIdFieldName" : "",
  "geometryType" : "esriGeometryPoint",
  "spatialReference" : {
    "wkid" : 4326
  },
  "fields" : [
    
  ],
  "features" : [
    {
      "geometry" : {
        "x" : 237.17180000000008,
        "y" : 38.844700000000046
      },
      "attributes" : {
        
      }
    },
    {
      "geometry" : {
        "x" : 242.89430000000004,
        "y" : 34.559200000000089
      },
      "attributes" : {
        
      }
    }
  ]
}

JSON Response example

When returnIdsOnly=false, returnCountOnly=false, outFields="", and geometryPrecision=3

{
  "objectIdFieldName" : "objectid",
  "globalIdFieldName" : "",
  "geometryType" : "esriGeometryPoint",
  "spatialReference" : {
    "wkid" : 4326
  },
  "fields" : [
    
  ],
  "features" : [
    {
      "geometry" : {
        "x" : 237.172,
        "y" : 38.845
      },
      "attributes" : {
        
      }
    },
    {
      "geometry" : {
        "x" : 242.894,
        "y" : 34.559
      },
      "attributes" : {
        
      }
    }
  ]
}

JSON Response example

When returnIdsOnly=true

{
  "objectIdFieldName" : "objectid", 
  "objectIds" : [1, 2, 3, 4, 5, 7]
}

JSON Response example

When returnCountOnly=true

{
  "count":48
}

JSON Response example

When returnGeometry=true and returnCentroid=true

{"geometryType" : "esriGeometryPolygon", 
  "features" : [
    {
      "attributes" : {"FID" : 6,}, 
      "geometry" : {"rings" : 
        [
          [
            [3665984.6341781, 4199764.97834117], 
            [3607400.16786144, 4129939.04834019], 
            [3593238.34218707, 4176854.4199198], 
            [3665984.6341781, 4199764.97834117]
          ]
        ]
      }, 
      "centroid" : 
      {
        "x" : 3702339.9805305949, 
        "y" : 4174890.1188574196
      }
    }
}

JSON Response example

When returnGeometry=false and returnCentroid=true

{
 "geometryType" : "esriGeometryPolygon", 
  "features" : [
    {
      "attributes" : {
        "FID" : 6, 
      }, 
      "centroid" : 
      {
        "x" : 3702339.9805305949, 
        "y" : 4174890.1188574196
      }
    }
}