API keys

An API key is a long term access token that you manually create, configure, and scope using the developer dashboard. Using API keys is typically the easiest way to access ArcGIS location services in your applications.

To use API keys, you need to have one of the following accounts:

  • ArcGIS Developer account
  • ArcGIS Online account

How to use an API key

You can use the developer dashboard to create and manage API keys to access location services. API keys can be scoped. This means you need to ensure you have properly scoped (enabled access) to the service(s) or content item(s) required in your application.

Steps

The typical workflow when using an API key in Esri Leaflet is to:

  1. Determine the API key scope required for the application.
  2. Create and scope an API key using your dashboard.
  3. Set the API key where authentication is required.

Example

Set an API key

Use dark colors for code blocks
     
1
2
3
4
5
  const apiKey = "YOUR_API_KEY";

  L.esri.Vector.vectorBasemapLayer("ArcGIS:Community",{
    apiKey: apiKey //Scoped to access the basemap layer service
  }).addTo(map);

To learn more, go to the Create an API key tutorial.

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