- URL:
- https://<root>/<serviceName>/FeatureServer/<layerId>/query
- Methods:
GET
- Required Capability:
- Query
- Version Introduced:
- 10.0
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 return
is set to true
) and/or a result extent (if return
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 return
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.
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 parameters table below.
To use pagination with aggregated queries (queries using either return
or out
with group
) on hosted feature services in ArcGIS Enterprise, the supports
property must be true
on the layer. Hosted feature services using a spatiotemporal data store do not currently support pagination on aggregated queries.
Features added throughout releases
New at 11.4
- Reference feature services have added support for the
return
parameter, which allows envelopes to be returned for features instead of geometries.Envelope - Reference feature services have added support for returning query results as pbf with control points.
- Full text search indexes can be created for hosted feature services using the Add to Definition operation. These indexes can then be used to perform full text queries using the layer-level Query operation. A new parameter,
full
, has been added to support full text searches.Text
New at 11.3
- Four new field types are now supported:
esri
,Field Type Time Only esri
,Field Type Date Only esri
,Field Type Timestamp Offset esri
.Field Type B i g Integer - Reference feature services will return control points in the JSON response from query results and accept features with control points when applying edits. Control points are special vertices used to apply symbol effects to line or polygon features. Geometries are persisted in the geodatabase with an identifier as to whether each vertex is a control point.
- This operation supports a new parameter,
default
, for hosted feature services. Setting theS R default
parameter allows the client to set the spatial reference information in one place rather than repeating it in several parameters when querying. This results in shorter requests which more often can be GET requests. Support forS R default
is indicated when the layer’sS R supports
property isDefault S R true
, underadvanced
.Query Capabilities - A new parameter,
return
, has been added. Support for this parameter is indicated when the layer’sEnvelope supports
property isReturning Geometry Envelope true
, underadvanced
.Query Capabilities - The
where
parameter now supports querying for either null or not null shapes using “shape is not null” or “shape is null” WHERE clause.
New at 11.2
- Operations that use
WHERE
clauses now support thecurrent_
keyword to refer to the currently connected federated Enterprise user. Theuser current_
keyword is supported when theuser supports
, underCurrent User Queries advanced
, isQuery Capabilities true
. This enhancement requires the server to havestandardized
enabled (Queries standardized
is enabled on the server by default).Queries - Feature services now support WKT2. Query parameters that take spatial references as input values will now accept a WKT2 value and generate an appropriate response. For WKT2 examples, see the following JSON example. For WKT2 values, see the Using spatial references documentation.
New at 11.0
At this release, feature services can be published from a Google BigQuery data source using ArcGIS Pro 3.0 or later.
- Date field values in a query response from a Google BigQuery feature service are assumed to be in UTC. Values from database fields of the
timestamp
type are accurate as they are returned from the database in UTC. Values from database fields of thetime
,date
, anddatetime
type may not be accurate as they may not be returned from the database in UTC. To avoid potential issues, feature services can be published from ArcGIS Pro that exclude the non-UTCtime
,date
, anddatetime
fields. - With Google BigQuery feature service layers, queries with
return
set asExtent Only true
are supported on point layers, but not on line and polygon layers. Support forreturn
asExtent Only true
is indicated when thesupports
property, underReturning Query Extent advanced
, isQuery Capabilities true
.
New at 10.9.1
A supported
property may be provided on the layer resource. This property describes the spatial relationships (the spatial
parameter) supported when querying the layer.
New at 10.9
-
A new parameter,
time
, has been added at 10.9. SettingReference Unknown Client time
asReference Unknown Client true
indicates that the client is capable of working with date field data values that are not in UTC. For more information on this parameter, see the Request parameters table below. -
The
multipatch
parameter supports a newOption extent
value. Extent is used to return the 3D extent of the multipatch features. This new value is supported when the feature layer'ssupportedmultipatch
property underOptions advanced
includesQuery Capabilities extent
:Use dark colors for code blocks Copy ... "supportedmultipatchOptions": [ "embedMaterials", "xyFootprint", "externalizeTextures", "stripMaterials", "extent" ], ...
-
Hosted feature services on a relational data store support SQL expressions for the
out
,Statistics group
, andB y order
parameters when theB y supports
, underS q l Expression advanced
, isQuery Capabilities true
. Hosted feature services in ArcGIS Online and non-hosted feature services in ArcGIS Enterprise already support this feature. -
Hosted feature services on a relational data store support SQL expression for the
out
parameter whenFields supports
, underO u t Field S q l Expression advanced
, isQuery Capabilities true
. Hosted feature services in ArcGIS Online already support this functionality.
10.8.1
- The layer query operation supports
percentile
as astatistic
when usingType out
for feature services published from ArcGIS Pro that reference enterprise geodatabase data. Layers that support percentiles include theStatistics supports
property asPercentile Statistics true
, found in theadvanced
layer object.Query Capabilities - Multipatch data can be queried with
multipatch
set asOption externalize
andTextures f
aspbf
for feature services published from ArcGIS Pro. - Non-hosted feature services published from ArcGIS Pro support an optimization for getting a layer's row count. By setting
where
as9999=9999
andreturn
asCount Only true
, the result is an approximate count that is returned very quickly. For accurate, but slower to return, row counts, use any other filter (e.g.where:
). This is only supported when a layer has both1=1 i
ands Data Versioned i
ass Data Archived false
.
10.8
The layer query operation supports percentile as a statistic
when using outstatistic
for hosted feature services in ArcGIS Online or ArcGIS Enterprise when run on a relational data store. Layers that support percentiles include the advanced
object property supports
as true
.
Request parameters
Parameter | Details |
---|---|
| A SQL-92
For information on how to format time and date information, see the Date-time queries section below. Examples
|
|
The object IDs of this layer or table to be queried. Syntax: Example: |
|
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:
Examples:
|
|
The type of geometry specified by the Values: |
| 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 |
|
The spatial relationship to be applied to the input At 10.9.1, a Values: |
| The spatial relate function that can be applied while performing the The string describes the spatial relationship to be tested when the spatial relationship is |
|
The time instant or the time extent to query. Time instant Syntax: Example: Time extent Syntax: Example: A null value specified for start time or end time will represent infinity for start or end time, respectively. Example: |
| The buffer distance for the input geometries. The distance unit is specified by Syntax
Example
|
| The unit for calculating the buffer distance. If Values: |
| 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
|
| If Values: |
| This option can be used to specify the Example
|
| 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
|
| Introduced at 11.3. This parameter sets the spatial reference for all other parameters in the request. For example, you can set the Support for |
| 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 When using |
| This option is a condition used with Values: |
|
The geodatabase version to query. This parameter applies only if the Syntax: Example: |
| If Values: |
| If 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 Values: |
| If Values: |
| If Values: |
| One or more field names on which the features/records need to be ordered. Use Syntax
Example
|
| One or more field names on which the values need to be grouped for calculating the statistics. Syntax
Example
|
| The definitions for one or more field-based statistics to be calculated. This parameter is supported only on layers/tables that indicate Syntax
Example
|
| If |
| If |
| This option dictates how the geometry of a multipatch feature will be returned. This parameter only applies if the layer's If A new
The z-coordinate units will match that of the underlying datasets' vertical coordinate system. When the vertical coordinate system is defined, the feature service layer includes properties to describe the VCS. It also includes a
Values: |
| This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, Example
|
| This option can be used for fetching query results up to the Example
|
| This option is supported by all feature services in ArcGIS Enterprise at 10.6.1. This is a JSON object used to project the geometry onto a virtual grid, likely representing pixels on the screen. The properties of the JSON object include Examples
|
| Used to return the geometry centroid associated with each feature returned. If Values: |
(Optional) | The Values: |
| This option works with ArcGIS Server services only. This is the historic moment to query. This parameter applies only if the layer is archiving enabled and the Syntax
Example
|
| When set to Values: |
| The Values: |
| This option is supported by most feature services, except for feature services published using a spatiotemporal data store. This parameter is When set to Values: |
| Introduced at 10.8. This parameter applies a datum transformation while projecting input geometries from their spatial reference to the layer's source spatial reference. When specifying transformations, you need to think about which datum transformation is best for this projection. For a list of valid datum transformation ID values and well-known text strings, see Using spatial references. For more information on datum transformations, see the transformation parameter in the Project operation. Syntax
Example
|
| Setting Its possible to define a service's time zone of date fields as unknown. Setting the time zone as unknown means that date values will be returned as-is from the database, rather than as date values in UTC. Non-hosted feature services can be set to use an unknown time zone using ArcGIS Server Manager. Setting the time zones to unknown also sets the Most clients released prior to ArcGIS Enterprise 10.9 will not be able to work with feature services that have an unknown time setting. The Value: |
| Introduced at 11.3. Specifies if the query will return the envelope of the geometry in the query results. Support for this parameter is indicated when the layer’s Values: |
| Introduced at 11.4. This parameter filters query results by performing a full text search on the layer's text fields. The search is performed on the full text search index, which can be created for a hosted feature service using the Add to Definition operation. A full text search processes results efficiently and is an alternative to using Syntax:
Example:
|
| The response format. The default response format is Example
The output format Values: |
Date-time queries
Time zone properties
In general, the date
property of the feature service layer identifies the time zone that all dates are stored in. The exception cases involve editor tracking date fields and time aware layer time zones.
When you are working with your data, you need to consider the time zone of the fields that you are working with. If you are querying a date type field and date
is 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:
Querying records in PST
where = pacific_time_date_field = TIMESTAMP '2015-02-09 13:00:00'
However, it is possible to have up to three different time zones defined on your service. If your query includes dates from the editor tracking fields or the time aware fields, you need to make sure you submit the query in their respective time zones. The time zones for these fields can be found in the properties mentioned above. If the date
is null the data is assumed to be in UTC, and if it is Unknown the time zone is assumed to be undefined. The example below demonstrates how to query three date fields that have three different times zones. When querying fields in different time zones, you need to make sure the time you use corresponds with the time zone of the date field. There is a date field in PST, one in EST, and the editor tracking field created_
in UTC:
Querying records in three different time zones
where = (DateTime_PST = TIMESTAMP '2012-01-01 15:20:00' AND (DateTime_EST = TIMESTAMP '2012-01-01 18:20:00' AND created_date = TIMESTAMP '2012-01-01 22:20:00'))
Although you issue local time in your WHERE clause, the query operation always returns date values in UTC. You can set the date fields time zone, which shows up in the date
property of the feature service layer either during publishing or in the ArcGIS Server Manager after publishing. In the Server Manager, navigate to service you wish to edit and click on the Parameters tab to update the time zone information. If the date
property is not set, it will show up as null and the data will be assumed to be in UTC. In this case make sure you issue your WHERE clause in UTC.
As of ArcGIS Pro 3.1 and ArcGIS Enterprise 10.9, there is a new option when defining the time zone during publishing. If you don't want to define a time zone at all (not even UTC), you can set it to Unknown. Using the Unknown time zone makes it so that there is no translation done when the query operation submits and returns date values, they are stored and returned as is. This is particularly useful if you have data which spans multiple time zones.
Date, time and time zone offset format
When Standardized
is enabled, use following SQL functions and syntaxes while querying against a date-time field. When Standardized
is turned off, you must consult to the underlying database's help references to find the correct syntax.
Field type | Description |
---|---|
| Values contain both date, time parts and time zone offset from UTC. The data and time represent local (or wall-clock) time. The time part supports milliseconds. SQL syntax
Example
|
| Values contain both date and time parts. The data and time represent local (or wall-clock) time, and are assumed in SQL syntax
Example
|
| Values contain only date part without associated to any particular time zone. SQL syntax
Example
|
| Values contains only time part without associated to any particular time zone. SQL syntax
Example
|
Interval queries
The INTERVAL
syntax can be used in place of the date-time queries and is standardized across all map and feature services. The INTERVAL syntax can be used to specify either the current date or timestamp in the query:
//Date
<DateField> >= CURRENT_DATE -+ INTERVAL '<IntervalValue>' <TimeStampFormat>
//Timestamp
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL '<IntervalValue>' <TimeStampFormat>
For the syntax demonstrated above, you can interchange the CURRENT_
and CURRENT_
values. Both can be used with +
or -
of INTERVAL
values.
The examples below outline the different ways in which the INTERVAL syntax can be modified for the purposes of your query:
//'DD' Day
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD' DAY
//'HH' Hour
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH' HOUR
//'MI' Minute
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'MI' MINUTE
//'SS(.FFF)' Second
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'SS(.FFF)' SECOND
//'DD HH' DAY TO HOUR
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH' DAY TO HOUR
//'DD HH:MI' DAY TO MINUTE
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH:MI' DTY TO MINUTE
//'DD HH:MI:SS(.FFF)' DAY TO SECOND
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'DD HH:MI:SS(.FFF)' DAY TO SECOND
//'HH:MI' HOUR TO MINUTE
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH:MI' HOUR TO MINUTE
//'HH:SS(.FFF)' HOUR TO SECOND
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'HH:SS(.FFF)' HOUR TO SECOND
//'MI:SS(.FFF)' MINUTE TO SECOND
<DateField> >= CURRENT_TIMESTAMP -+ INTERVAL 'MI:SS(.FFF)' MINUTE TO SECOND
To demonstrate the INTERVAL
format, the example below uses the INTERVAL syntax to query data gathered over the 3 days, 5 hours, 32 minutes, and 28 seconds:
DateField >= CURRENT_TIMESTAMP - INTERVAL '3 05:32:28' DAY TO SECOND
Percentile statistic type
The percentile statistic
is supported if the supports
layer property (in advanced
) is true
. The percentile indicates the value below or above which a given percentage of values in a group of data values falls. For example, the ninetieth percentile (value 0.9) is the value below which 90 percent of the data values may be found. For percentile statistics, there are two statistic
, PERCENTILE_
(discrete) and PERCENTILE_
(continuous). Discrete returns a data value from within that dataset while continuous is an interpolated value.
The order
statistic parameter can also be used to calculate the percentile. For example, in a set of 10 values from 1 to 10, the percentile value
for 0.9 with order
set as ascending (ASC
) is 9, while the percentile for value
0.9 with order
set as descending (DESC
) is 2. The default is ASC
.
Syntax
[
{
"statisticType": "<PERCENTILE_CONT | PERCENTILE_DISC>",
"statisticParameters": {
"value": percentile_value,
"orderBy": "<ASC | DESC>"
},
"onStatisticField": "Field1",
"outStatisticFieldName": "Out_Field_Name1"
},
{
"statisticType": "<PERCENTILE_CONT | PERCENTILE_DISC>",
"statisticParameters": {
"value": percentile_value,
"orderBy": "<ASC | DESC>"
},
"onStatisticField": "Field2",
"outStatisticFieldName": "Out_Field_Name2"
}
]
Example
[
{
"statisticType": "PERCENTILE_CONT",
"statisticParameters": {
"value": 0.9
},
"onStatisticField": "NEAR_DIST",
"outStatisticFieldName": "pop90_cont"
},
{
"statisticType": "PERCENTILE_DISC",
"statisticParameters": {
"value": 0.9,
"orderBy": "DESC"
},
"onStatisticField": "population",
"outStatisticFieldName": "pop90_desc"
}
]
Quantization parameters JSON properties
Property | Description |
---|---|
| 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. |
| Geometry coordinates are optimized for viewing and displaying of data. The view value specifies that geometry coordinates should be optimized for viewing and displaying of data. The edit value specifies that full-resolution geometries should be returned, which can support lossless editing. Value: |
| Integer coordinates will be returned relative to the origin position defined by this property value. The default value is Values: |
| 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 If |
Return type and max record count
The max
and max
are determined by the server and display in the layer metadata. The feature service assigns the max
relevant to the value from the result
parameter. If result
is not included in the request, the default max
is always used. This can be the default server-assigned value (1000, 2000) or an overwritten value provided by the service owner or admin. The values of the max record counts might vary based on the type of the data (polygon, point, polyline, table).
If the result
is specified, but the result
is not specified with the result
, the server will determine the max
relevant to the result
query parameter. The client can supply the result
parameter in the request. This cannot be greater than the standard/tile max
value if result
is used.
The layer metadata also includes maxRecordCountFactor that can be configured from the admin API. The server max
for the tile
and standard
is used as a multiplier for the server base value. All max
values are adjusted with the max
.
Pagination query also supports the result
query parameter.
SQL format
The table summarizes the sql
parameter and what you can expect from the query API.
sqlFormat value | useStandardizedQuery is true | useStandardizedQuery is false |
---|---|---|
standard (sql'92) | Yes | Yes |
native (native DBMS sql) | Not supported | Yes |
none | Only sql'92 (means standard) | Only DBMS native SQL (native) |
Full text searches
A full text search can only be applied to fields with the type esri
that have already had an index
of Full
created for them. You can determine if a field has a Full
index by checking the indexes on the layer resource. An error is returned if you try to search a field that does not have a full text search index.
The table below outlines the syntax for the full
parameter.
Fields | Description |
---|---|
| The list of layer field's the serach will be performed on. |
| The term being searched for in the layer's fields. If
|
| The type of search being performed. The following are the accepted types of searches:
|
| The conjunctive operator used between Values: |
The tabs below outline a number of examples for the full
parameter and describe the searches being performed:
This example demonstrates a full text search on a layer's notes
field that is searching for the words “broken pipe”. Having a search
of simple
means that any values that have both the words "broken" and "pipe", in any order, will be a match. For example, a note
field with the text of “the pipe is broken” would result in a match for this search.
fullText=[{"onFields":["notes"],"searchTerm":"broken pipe","searchType":"simple"}]
This example demonstrates a full text search on a layer's notes
field, utilizing the or
operator, that is searching for either the words “broken" or "pipe”. Using the or
operator means that any values that have either "broken" or "pipe" will be a match. For example, a note
field with the text of “there is a burst pipe” would result in a match for this search.
fullText=[{"onFields":["notes"],"searchTerm":"broken pipe","searchType":"simple","operator":"or"}]
This example demonstrates a full text search on a layer's notes
field, utilizing the not
operator, that is searching for instances of “broken" that do not include the word "pipe”. Using the not
operator means that the search looks for matches that include just the first word of the search
and do not include any of the additional words specified in search
. For example, a note
field with the text of "the fence is broken" would result in a match for this search, whereas a note
field with the text of "the pipe is broken" would not be counted as a match.
fullText=[{"onFields":["notes"],"searchTerm":"broken pipe","searchType":"simple","operator":"not"}]
This example demonstrates a full text search on two layer fields, notes
and comments
, that is searching for the words “broken pipe”. Having a search
of simple
means that any values from either the notes
or comments
fields that include both "broken" and "pipe", in any order, will be a match.
fullText=[{"onFields":["notes",”comments”],"searchTerm":"broken pipe","searchType":"simple"}]
This example demonstrates a full text search on two layer fields, notes
and comments
, that is searching for the words “broken pipe”. Having a search
of prefix
means that the search looks for phrases from the notes
and comments
that match the beginning letters of each word included in search
. For example, a note
field with the text of "brok pipe" will be counted as a match, but a note
field with the text of "broken copper pipe" would not be counted as a match, as the phrase does not match.
fullText=[{"onFields":["notes",”comments”],"searchTerm":"broken pipe","searchType":"prefix"}]
This example demonstrates multiple full text search expressions. The first search expression searches the note
field for the word "broken". The second search expression searches the status
field for the word "assigned". The results from both searches are combined with an and
operator. When more search expressions are included, the results are based on the intersection of each result.
fullText=[{"onFields":["notes"],"searchTerm":"broken","searchType":"prefix"}, {"onFields":["status"],"searchTerm":"assigned","searchType":"simple"}]
Example usage
Example one
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause:
https://machine.domain.com/webadaptor/rest/services/Earthquakes/EarthquakesFromLastSevenDays/FeatureServer/0/query?where=magnitude+%3E+4.5&outFields=*&returnGeometry=true&returnIdsOnly=false&f=html
Example two
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause and returning only OBJECTIDs
:
https://machine.domain.com/webadaptor/rest/services/SanFrancisco/311Incidents/FeatureServer/1/query?where=agree_with_incident+%3D+1&returnGeometry=true&returnIdsOnly=true&f=html
Example three
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause using the DAY format:
https://machine.domain.com/webadaptor/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?
where=date_time > CURRENT_TIMESTAMP - INTERVAL '1' DAY&returnGeometry=false&returnCountOnly=true&resultType=&f=pjson
Example four
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause that has the DAY TO HOUR format:
https://machine.domain.com/webadaptor/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?
where=date_time > CURRENT_TIMESTAMP + INTERVAL '1 04' DAY TO HOUR&returnGeometry=false&returnCountOnly=true&resultType=&f=pjson
Example five
The following is a sample request URL for the query
operation, which demonstrates how to page through a query result using the result
and result
parameters to get the next set of results. Specifically, the example below shows a request that skips the first 5 records and return the next 10 counties in California, ordered by population:
https://machine.domain.com/webadaptor/rest/services/USA/MapServer/3/query?where=STATE_NAME='California'&outFields=Name,Population&returnGeometry=false&resultOffset=5&resultRecordCount=10&orderByFields=Population&f=pjson
Example six
The following is a sample request URL for the query
operation, which demonstrates a query that has result
is set to none
:
https://machine.domain.com/webadaptor/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 seven
The following is a sample request URL for the query
operation, which demonstrates a query that has result
is set to standard
:
https://machine.domain.com/webadaptor/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 eight
The following is a sample request URL for the query
operation, which demonstrates a query that has result
is set to tile
:
https://machine.domain.com/webadaptor/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=
Example nine
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause to find field values equal to the currently connected federated Enterprise user:
https://machine.domain.com/webadaptor/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?where=workerfield=current_user &returnGeometry=false&returnCountOnly=true&resultType=&f=pjson
Example ten
The following is a sample request URL for the query
operation, which demonstrates a query using a WHERE clause to find field values that include currently connected federated Enterprise user:
https://machine.domain.com/webadaptor/rest/services/DateTimeIntervalQuery/FeatureServer/0/query?where=position(current_user in workersfield)>0 &returnGeometry=false&returnCountOnly=true&resultType=&f=pjson
JSON Response syntax
Example one
The sample JSON response syntax below shows the response forma returned when return
is set to false
and return
is set to 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>
]
}
Example two
The sample JSON response syntax below shows the response forma returned when return
is set to true
:
{
"count": <count>
}
Example three
The sample JSON response syntax below shows the response forma returned when return
is set to true
and return
is set to true
:
{
"count": <count>,
"extent": <envelope>
}
Example four
The sample JSON response syntax below shows the response forma returned when return
is set to true
:
{
"objectIdFieldName": "<objectIdFieldName>",
"objectIds": [ <objectId1>, <objectId2> ]
}
JSON Response example
Example one
The following JSON response example is returned when return
is set to false
and return
is set to 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"
}
}
]
}
Example two
The following JSON response example is returned when return
is set to false
, return
is set to false
, and out
is not specified:
{
"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": {}
}
]
}
Example three
The following JSON response example is returned when return
is set to false
, return
is set to false
, out
is not specified, and geometry
is set to 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": {}
}
]
}
Example four
The following JSON response example is returned when return
is set to true
:
{
"objectIdFieldName": "objectid",
"objectIds": [1, 2, 3, 4, 5, 7]
}
Example five
The following JSON response example is returned when return
is set to true
:
{
"count": 48
}
Example six
The following JSON response example is returned when return
is set to true
and return
is set to 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
}
}
]
}
Example seven
The following JSON response example is returned when return
is set to false
and return
is set to true
:
{
"geometryType": "esriGeometryPolygon",
"features": [
{
"attributes" : {
"FID" : 6,
},
"centroid" : {
"x" : 3702339.9805305949,
"y" : 4174890.1188574196
}
}
]
}
Example eight
The following JSON response example is returned when multipatch
is set to extent
and return
is true
for layers with multipatch geometries:
{
"objectIdFieldName": "objectid",
"globalIdFieldName": "globalid",
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326,
"vcsWkid": 5702,
"latestVcsWkid": 5702
},
"hasZ": true,
…
"features": [
{
"attributes": {
"objectid": 30,
"region": 8,
"globalid": "{37CA67AE-53DA-41BC-94C1-80DEC8D46C8D}"
},
"geometry": {
"hasZ": true,
"rings": [
[
[
8.5387978810035712,
47.376115083562929,
405.07499999999709
],
[
8.5387978810035712,
47.376514765273249,
405.07499999999709
],
[
8.5394347730652775,
47.376514765273249,
432.96700000000419
],
[
8.5394347730652775,
47.376115083562929,
405.07499999999709
],
[
8.5387978810035712,
47.376115083562929,
405.07499999999709
]
]
]
}
}
]
}
Example nine
The following JSON response example is returned when the geometry has control points. The control points are described in the ids
array. The index of each ids
array value matches up with the vertex at the same index in the geometry. An ids
array value of 1 means that it is a control point vertex while a value of 0 means that it is not a control point vertex.
{
"objectIdFieldName": "OBJECTID",
"globalIdFieldName": "GlobalID",
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"hasZ": false,
"fields": [
{
"name": "OBJECTID",
"alias": "OBJECTID",
"type": "esriFieldTypeOID"
}
],
"features": [
{
"attributes": {
"OBJECTID": 2
},
"geometry": {
"paths": [
[
[
-13123272.572900001,
3495029.6371000037
],
[
-12883437.2676,
3497028.2646000013
],
[
-12744038.6544,
3498189.9196999967
],
[
-12631303.591699999,
3499129.3786000013
]
]
],
"ids": [
[
0,
1,
1,
0
]
]
}
}
]
}
Example ten
This example shows the new date and bigInteger field types, which are supported at starting ArGIS Enterprise 11.3. Previously, these were beta features at ArGIS Enterprise 11.2. The following JSON response example is returned when return
is false
, out
includes the timestampfld
, dateonlyfld
, timeonlyfld
,abigint
fields and object
is 3150
:
{
"objectIdFieldName": "OBJECTID",
"globalIdFieldName": "GlobalID",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4267,
"latestWkid": 4267
},
"fields": [
{
"name": "timestampfld",
"alias": "timestampfld",
"type": "esriFieldTypeTimestampOffset"
},
{
"name": "dateonlyfld",
"alias": "dateonlyfld",
"type": "esriFieldTypeDateOnly",
"length": 8
},
{
"name": "timeonlyfld",
"alias": "timeonlyfld",
"type": "esriFieldTypeTimeOnly",
"length": 8
},
{
"name": "abigint",
"alias": "abigint",
"type": "esriFieldTypeBigInteger"
}
],
"features": [
{
"attributes": {
"timestampfld": "2023-05-03T11:44:08-07:00",
"dateonlyfld": "1899-12-30",
"timeonlyfld": "15:54:36",
"abigint": 10111222333
}
}
]
}
Example eleven
This example shows WHERE clauses with the esri
field. For this example, the data is as follows:
OBJECTID | timestampfld |
---|---|
1 | 2003-01-25 14:00:00 -08:00 |
2 | 2003-01-25 14:00:00 -05:00 |
3 | 2003-01-25 17:00:00 -05:00 |
If the where
parameter is set to a timestampfld
of 2003-01-25 14:00:00 -08:00
, rows will be matched based on absolute (UTC) time. This means that rows 1 and 3 are returned, as they reflect the same absolute time when convereted to UTC. This configuraiton would be useful if, for example, you wanted to see what traffic was like across the country at a specific moment in time:
{
"objectIdFieldName": "OBJECTID",
"globalIdFieldName": "GlobalID",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4267,
"latestWkid": 4267
},
"fields": [
{
"name": "OBJECTID",
"alias": "OBJECTID",
"type": "esriFieldTypeOID",
"length": 8
},
{
"name": "timestampfld",
"alias": "timestampfld",
"type": "esriFieldTypeTimestampOffset"
}
],
"features": [
{
"attributes": {
"OBJECTID": 1,
"timestampfld": "2003-01-25T14:00:00-08:00"
}
},
{
"attributes": {
"OBJECTID": 3,
"timestampfld": "2003-01-25T17:00:00-05:00"
}
}
]
}
Rows can also be matched based on their local time. If the where
parameter was set in the following way:
cast(timestampfld as timestamp) = timestamp '2003-01-25 14:00:00'
both rows 1 and 2 would be returned, as both timestamps represent 2 pm in their local timezone. This configuraiton would be useful if, for example, you wanted to see what traffic was like just before rush hour using local time (for example, 2 pm in each timezone) across the country.
{
"objectIdFieldName": "OBJECTID",
"globalIdFieldName": "GlobalID",
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4267,
"latestWkid": 4267
},
"fields": [
{
"name": "OBJECTID",
"alias": "OBJECTID",
"type": "esriFieldTypeOID",
"length": 8
},
{
"name": "timestampfld",
"alias": "timestampfld",
"type": "esriFieldTypeTimestampOffset"
}
],
"features": [
{
"attributes": {
"OBJECTID": 1,
"timestampfld": "2003-01-25T14:00:00-08:00"
}
},
{
"attributes": {
"OBJECTID": 2,
"timestampfld": "2003-01-25T14:00:00-05:00"
}
}
]
}
Example twelve
The following JSON response example is returned when retrun
is true
.
{
"features": [
{
"envelope": {
"xmin": -1.3885038430195604e7,
"ymin": 5707454.569268562,
"xmax": -1.3015269129041411e7,
"ymax": 6274862.04128094
},
"centroid": {
"x": -1.3405501208218541e7,
"y": 6007537.146588812
},
"attributes": {
"state_name": "Washington"
},
"geometry": {
"rings": [
[
[
-1.3625589074387547e7,
6144434.816338301
],
[
-1.363236139509361e7,
6144960.703618102
],
..........
..........
..........
[
-1.366245295452885e7,
6153032.828067109
]
]
]
}
}
],
"spatialReference": {
"latestWkid": 3857,
"wkid": 102100
},
"geometryType": "esriGeometryPolygon"
}