Introduction to data services

You can import and publish data using to create hosted layers and services in ArcGIS. Once created, you can access the layers and services using the feature service package from ArcGIS REST JS to return metadata, make queries, edit features, and perform other operations.

Workflow

The general workflow to work with the helper methods from the feature service package is to:

  1. Import your data from a CSV, XLS, GeoJSON, or Shapefile file to create a hosted feature layer. See Import data as a feature layer.
  2. Get the URL for the feature layer. See Access feature layer data.
  3. Make a request to the service.

Access feature layer data

To access feature layer data, you use the getService operation and the feature layer URL to access the metadata.

Example

1
2
3
4
5
6
7
import { getService } from '@esri/arcgis-rest-feature-service';

getService("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0", {
  authentication
}).then((metadata) => {
  console.log(metadata);
})

Query features

With the service URL from a published hosted feature layer, you can use the queryFeatures function to perform either SQL or spatial queries against the .

Example

This example demonstrates how to perform a SQL query against a feature service.

1
2
3
4
5
6
7
8
9
10
import { queryFeatures } from '@esri/arcgis-rest-feature-service';

queryFeatures({
  url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0",
  where: "UseType = 'Residential'",
  resultRecordCount: 1,
  authentication
}).then((results) => {
  console.log(results);
})

Edit features

You can add, update, and delete features from a feature layer using addFeatures, updateFeatures, and deleteFeatures.

Example

This example shows how to add features to a feature layer.

1
2
3
4
5
6
7
8
9
import { addFeatures } from '@esri/arcgis-rest-feature-service';

addFeatures({
  url: featureServiceLayerUrl,
  features: [featureToAdd],
  authentication
}).then((results) => {
  console.log(results);
})

Tutorials

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close