Key concepts

This document provides an overview of how to work with ArcGIS REST JS to build mapping applications. ArcGIS REST JS is library that contains a collection of packages that are framework agnostic. Implementing ArcGIS Rest JS packages allows you to:

  • Simplify making requests to ArcGIS Online, ArcGIS Enterprise, and ArcGIS Platform location service REST APIs.
  • Use CDN, NodeJS, or tree-shakeable ES modules.
  • Work with popular module bundlers like: webpack, Rollup, and Parcel.


To make requests to services, you reference packages in the library in your application. These packages provide helpers that allow you to make low-level requests, authenticate users, query, geocode, route, and access demographic data.

Referencing libraries

Here is an example of how to reference libraries using different frameworks.

CDNES ModulesNode JS
<!DOCTYPE html>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>ArcGIS REST JS</title>
    body {
      font-family: monospace;
      color: white;
    pre {
      overflow: auto;
      padding: 1rem;
      background: #000000;
  <pre id="result"></pre>

  <!-- require ArcGIS REST JS libraries from -->
  <script src=""></script>
  <script src=""></script>
  <script src=""></script>

    /* when including ArcGIS REST JS all exports are available
    from the same arcgisRest global */

    const apiKey = "YOUR-API-KEY";

    const authentication = new arcgisRest.ApiKey({
      key: apiKey

      params: {
        category: 'Coffee shop',
        location: '144.9850916862488,-37.798297645411',
        distance: 2000,
        maxLocations: 20
      outFields: '*',
    }).then((response) => {
      console.log("Candidates:", response.candidates);
      document.getElementById("result").textContent = JSON.stringify(response.candidates, null, 2);




ArcGIS REST JS handles both API key and OAuth 2.0 methods of authentication. Visit Security and authentication to learn more about API keys and OAuth2.0 in the Mapping APIs and location services guide.

API key

If your application needs to access location services, use an API Key from your developer dashboard. When using an API key, make sure that it is properly scoped to the services you are accessing.

  1. Reference the library.
  2. Get an API key from your dashboard.
  3. Set the API key.
import { request } from "@esri/arcgis-rest-request";
import { ApiKey } from "@esri/arcgis-rest-auth";

const apiKey = "YOUR-API-KEY";

const authentication = new arcgisRest.ApiKey({
  key: apiKey

To learn more, go to the tutorials.

OAuth 2.0

When your app requires access to Esri secure user content or if you are distributing your app through ArcGIS Marketplace, you should implement OAuth 2.0 to obtain an ArcGIS identity.

The ArcGIS REST JS authentication package includes modules such as UserSession to authenticate users with their ArcGIS Online or ArcGIS Enterprise accounts. Other OAuth 2.0 calls you can use include generating and exchanging tokens.

  1. Reference the library.
  2. Go to your dashboard.
  3. Create or use an existing application.
  4. Get the client ID from your application.
  5. Set the client ID.

import {request} from "@esri/arcgis-rest-request";
import { UserSession } from '@esri/arcgis-rest-auth';
// register your own app to create a unique clientId
const clientId = "abc123"

  redirectUri: ''

Working with location services

ArcGIS location services includes a number of services for geocoding, routing, demographic analysis, and spatial analysis. In ArcGIS REST JS, there are libraries for accessing each of the different services and functionality. To learn more, visit the tutorials.


The typical steps for accessing a service is to:

  1. Reference the appropriate libraries.
  2. Set the API key to authenticate the request.
  3. Define parameters to pass to the service.
  4. Call the service and handle the results.

Geocoding service


import { ApiKey } from "@esri/arcgis-rest-auth";
import { geocode } from "@esri/arcgis-rest-geocoding";

const authentication = new ApiKey({
  key: apiKey

  address: "1600 Pennsylvania Ave",
  postal: 20500,
  countryCode: "USA",

To learn more, go to the Search for an address tutorial.

Routing service


import { ApiKey } from "@esri/arcgis-rest-auth";
import { solveRoute } from "@esri/arcgis-rest-routing";

const authentication = new ApiKey({
  key: apiKey

  stops: [
    [-117.195677, 34.056383],
    [-117.918976, 33.812092]

To learn more, go to the Find a route and directions tutorial.

Working with hosted feature layers

You can use ArcGIS REST JS to access your own data through services hosted in the ArcGIS Platform. To create hosted layers and services, you can import and publish data using data management tools. Once created, you can access the layers and services using ArcGIS REST JS.

  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 to access metadata.

Access hosted feature layer data

After your data is hosted, you can access the metadata with a URL.

arcgisRest.request("", {

To learn more, go to the Get layer metadata tutorial.

Query and edit hosted feature layer data

With the service URL from a published hosted feature layer, you can make different requests to the service using feature layer helpers to query and edit features.


Use a SQL where clause or spatial queries to access subsets of data in a hosted feature layer.


  url: "",
  where: "UseType = 'Residential'",
  resultRecordCount: 1,

To learn more, go to the Query a feature layer (SQL) tutorial.


Add, update, and delete features in a hosted feature layer.


      url: featureServiceLayerUrl,
      features: [featureToAdd],

To learn more, go to the Edit feature data tutorial.


Here are some useful resources to help create applications with ArcGIS REST JS and ArcGIS location services: