A feature layer can contain a large number of features. To access a subset of these features, you can execute an SQL or spatial query, either together or individually. The results can contain the attributes, geometry, or both for each record. SQL and spatial queries are useful when a feature layer is very large and you want to access only a subset of its data.
In this tutorial, you access and query a hosted feature layer with a geometry and spatial operator to only return intersecting records.
Prerequisites
You need a free ArcGIS developer account to access your dashboard and API keys. The API key must be scoped to access the services used in this tutorial.
Steps
Create a new pen
If you are using the CDN libraries, to get started.
Make the request
Copy and paste the code below, following the steps to make a request to the feature service.
Reference the ArcGIS REST JS libraries either through CDN, ES Modules, or Node JS.
Set the apiKey with the API key from your dashboard.