<div class="grid-container padding-leader-1 padding-trailer-3">
  <h1>Query all features from a feature service using ArcGIS REST JS</h1>
  <div class="wrapper column-24">
    <p>When querying an ArcGIS Feature Service, there is typically a maximum number of features (records) that will be returned from any query – usually set to 1000. If you want to get <em>all</em> the features in the service, ArcGIS REST JS does not currently do this (see <a href="https://github.com/Esri/arcgis-rest-js/issues/690">this issue</a>) -  you’ll need to make multiple queries to the service. Use the package <a href="https://www.npmjs.com/package/query-all-features">query-all-features</a> to do this.</p>
    <p id="errorDomNode" class="error alert alert-red"> </p>
    <pre class="results" id="resultsDomNode"><span style="color:gray">[none yet]</span></pre>
.wrapper {
  .results {
    font-family: monospace;
// Similar version that uses the ArcGIS API for JavaScript instead of ArcGIS REST JS:
// https://codepen.io/gavinr/pen/QWEdgZw?editors=0010

// For more info on usage: https://www.npmjs.com/package/query-all-features
import { queryAllFeatures } from "https://cdn.skypack.dev/query-all-features";

  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
}).then((results) => {
  console.log('results', results);
  resultsDomNode.innerHTML = `${results.features.length} results: <br /><br />` +  JSON.stringify(results, null, 4);
}, (err) => {
  console.log('err', err);
  errorDomNode.innerHTML = err;

External CSS

  1. https://s3-us-west-1.amazonaws.com/patterns.esri.com/files/calcite-web/1.2.5/css/calcite-web.min.css

External JavaScript

This Pen doesn't use any external JavaScript resources.