FRAMES | NO FRAMES Description | Parameters | Examples | Response
Query Layer (Operation)
URL http://<layer-url>/query
Parent Resource Layer




The query operation is performed on a layer resource. The result of this operation is a resultset resource. This resource provides information about query results including the values for the fields requested by the user. If you request geometry information, the geometry of each result is also returned in the resultset.

You can provide arguments to the query operation as query parameters defined in the parameters table below.


Parameter Details
f Description: The response format. The default response format is html.

Values: html | json | kmz
text Description: A literal search text. If the layer has a display field associated with it, the server searches for this text in this field. This parameter is a short hand for a where clause of:
where <displayField> like '%<text>%'
. The text is case sensitive.
This parameter is ignored if the where parameter is specified.

Example: text=Los
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, for envelopes and points, you can specify the geometry with a simpler comma-separated 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>
  • 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, point, line, or polygon. The default geometry type is an envelope.

Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope
inSR Description: The well-known ID of the spatial reference of the input geometry. 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 on the input geometry while performing the query. The supported spatial relationships include intersects, contains, envelope intersects, within, etc. The default spatial relationship is intersects (esriSpatialRelIntersects).

Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin
where Description: A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.

Example: where=POP2000 > 350000
outFields Description: The list of fields to be included in the returned resultset. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. To request geometry, set returnGeometry to true.

You can also specify the wildcard "*" as the value of this parameter. In this case, the query results include all the field values. Note that the wildcard also implicitly implies returnGeometry=true and setting returnGeometry to false will have no effect.

Example: outFields=AREANAME,ST,POP2000
Example (wildcard usage): outFields=*
returnGeometry Description: If true, the resultset includes the geometry associated with each result. The default is true.

Note that if the outFields parameter is set to the wildcard "*", it implicitly implies returnGeometry=true and setting returnGeometry to false has no effect.

Values: true | false
outSR Description: The well-known ID of the spatial reference for the returned geometry. If outSR is not specified, the geometry is returned in the spatial reference of the map.

Example Usage

Example 1: Query using the text parameter on the states layer of the ESRI_StateCityHighway_USA on sampleserver1:

Example 2: Query using a where statement on the same layer. The output is JSON format:'Florida'&f=json

Example 3: Query strings are case sensitive. In this example, UPPER is used to make the query case insensitive:'colorado')

Example 4: Querying the same states layer using geometry (envelope):,35.2,-118.7,43.8&geometryType=esriGeometryEnvelope

Example 5: Querying the states layer by both geometry (envelope) and a where statement:,35.2,-118.7,43.8&geometryType=esriGeometryEnvelope&where=POP1999>5000000

Example 6: Querying the states layer by where statement, specifying a list of fields to return, and requesting no geometry in the results:>15000000&returnGeometry=false&outFields=STATE_NAME,MALES,FEMALES,POP1999

Example 7: Querying the states layer by text parameter and requesting the geometry with the well-known ID of 102113 (Web Mercator):

JSON Response Syntax

"displayFieldName" : "<displayFieldName>",
"fieldAliases" : {
"<fieldName1>" : "<fieldAlias1>",
"<fieldName2>" : "<fieldAlias2>"
"geometryType" : "<geometryType>",
"spatialReference" : {
"features" : [
"attributes" : {
"<fieldName1>" : <fieldValue11>,
"<fieldName2>" : <fieldValue21>
"geometry" : {<geometry1>}
"name" : "<featureName2>",
"attributes" : {
"<fieldName1>" : <fieldValue12>,
"<fieldName2>" : <fieldValue22>
"geometry" : {<geometry2>}

JSON Response Example

"displayFieldName" : "AREANAME",
"fieldAliases" : {
"ST" : "ST",
"POP2000" : "Population - 2000",
"AREANAME" : "City Name"
"geometryType" : "esriGeometryPoint",
"spatialReference" : {"wkid" : 4326},
"features" : [
"attributes" : {
"ST" : "CA",
"POP2000" : 3694820,
"AREANAME" : "Los Angeles"
"geometry" : { "x" : -118.37, "y" : 34.086 }
"attributes" : {
"ST" : "CA",
"POP2000" : 461522,
"AREANAME" : "Long Beach"
"geometry" : { "x" : -118.15, "y" : 33.80 }