Skip to content

Hosted data services provide a way to store, manage, and access your own geographic data for maps. You can store data in ArcGIS as features, then access, query, and edit the data with the arcgis-rest-routing package.

Steps
  1. Import your data from a CSV, XLS, GeoJSON, or Shapefile file to create a hosted feature layer.
  2. Get the URL for the feature layer.
  3. Install and reference the arcgis-rest-feature-service and arcgis-rest-request packages.
  4. Set an access token to authenticate the request.
  5. Make a request to the service.

Access metadata

Accessing metadata allows you to retrieve detailed information about a feature layer, such its the owner, item ID, structure, fields, and settings.

Get layer metadata

Learn how to get layer metadata with the getService method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { getService } from "@esri/arcgis-rest-feature-service";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

getService("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0", {
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Query features

Querying features enables you to request specific records from a feature service based on attribute criteria (SQL) or spatial relationships.

Query a feature layer

Learn how to perform an SQL query against a feature layer with the queryFeatures method.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { queryFeatures } from "@esri/arcgis-rest-feature-service";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

queryFeatures({
  url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/LA_County_Parcels/FeatureServer/0",
  where: "UseType = 'Residential'",
  resultRecordCount: 1,
  authentication
}).then((response) => {
  console.log(JSON.stringify(response, null, 2));
});
Go to tutorial

Edit features

Editing features allows you to modify the content of a feature layer by adding new records, updating existing ones, or removing outdated data.

Edit feature data

Learn how to add, update, and delete features from a feature layer using the addFeatures, updateFeatures, and deleteFeatures methods.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { addFeatures, updateFeatures, deleteFeatures } from "@esri/arcgis-rest-feature-service";

const accessToken = "YOUR_ACCESS_TOKEN";
const authentication = ApiKeyManager.fromKey(accessToken);

const featureServiceLayerUrl = "https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/my_points/FeatureServer/0";

const featureToAdd = {
  attributes: {
    id: 101,
    name: "editing test",
    rating: "2"
  },
  geometry: {
    x: -118.807,
    y: 34.002,
    spatialReference: {
      wkid: 4326
Expand
Go to tutorial

More resources

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