Skip to content
Types
import type { APIKeyMixin } from "@arcgis/core/layers/mixins/APIKeyMixin.js";
Subclasses:
BuildingSceneLayer, CatalogLayer, FeatureLayer, GaussianSplatLayer, IntegratedMesh3DTilesLayer, IntegratedMeshLayer, MapImageLayer, OGCFeatureLayer, PointCloudLayer, SceneLayer, SubtypeGroupLayer, TileLayer, VectorTileLayer, VoxelLayer
Since
ArcGIS Maps SDK for JavaScript 4.20

APIKeyMixin adds an apiKey property to layers and ensures that the key is included in all outgoing requests performed by those layers.

Properties

PropertyTypeClass

apiKey

Property
Type
string | null | undefined

An authorization string used to access a resource or service. This property will append the API key to all requests made by the layer to the service. API keys are generated and managed in the portal. An API key is tied explicitly to an ArcGIS account; it is also used to monitor service usage. Setting a fine-grained API key on a specific class overrides the global API key.

If loading a secure layer with API authentication via a PortalItem, the API key needs to be set on the layer's portalItem property.

See also
Example
// set the api key to access a protected service
const layer = new FeatureLayer({
url: serviceUrl,
apiKey: "YOUR_API_KEY"
});