queryFeatures

Function
queryFeatures(requestOptions: IQueryFeaturesOptions & { f: "json" }): Promise<IQueryFeaturesResponse | IQueryResponse>

Query a feature service. See REST Documentation for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
import { queryFeatures } from '@esri/arcgis-rest-feature-service';

const response = await queryFeatures({
 url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
 where: "STATE_NAME = 'Alaska'"
});

TypeScript note: return types for queryFeatures() depend on the literal value of f . Inline objects infer literal f values automatically, but pre-declared objects may widen f to string . To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson" as const
};

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
};

const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
} satisfies IQueryFeaturesOptions;

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection

Parameters

ParameterTypeNotes
requestOptionsIQueryFeaturesOptions & { f: "json" }

Options for the request

Returns 

Promise<IQueryFeaturesResponse | IQueryResponse>

A Promise that will resolve with the query response.

queryFeatures(requestOptions: IQueryFeaturesOptions & { f: "geojson" | "pbf-as-geojson" }): Promise<EsriGeoJSONFeatureCollection>

Query a feature service. See REST Documentation for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
import { queryFeatures } from '@esri/arcgis-rest-feature-service';

const response = await queryFeatures({
 url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
 where: "STATE_NAME = 'Alaska'"
});

TypeScript note: return types for queryFeatures() depend on the literal value of f . Inline objects infer literal f values automatically, but pre-declared objects may widen f to string . To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson" as const
};

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
};

const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
} satisfies IQueryFeaturesOptions;

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection

Parameters

ParameterTypeNotes
requestOptionsIQueryFeaturesOptions & { f: "geojson" | "pbf-as-geojson" }

Options for the request

Returns 

Promise<EsriGeoJSONFeatureCollection>

A Promise that will resolve with the query response.

queryFeatures(requestOptions: IQueryFeaturesOptions & { f: "pbf-as-arcgis" }): Promise<IQueryFeaturesResponse>

Query a feature service. See REST Documentation for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
import { queryFeatures } from '@esri/arcgis-rest-feature-service';

const response = await queryFeatures({
 url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
 where: "STATE_NAME = 'Alaska'"
});

TypeScript note: return types for queryFeatures() depend on the literal value of f . Inline objects infer literal f values automatically, but pre-declared objects may widen f to string . To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson" as const
};

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
};

const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
} satisfies IQueryFeaturesOptions;

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection

Parameters

ParameterTypeNotes
requestOptionsIQueryFeaturesOptions & { f: "pbf-as-arcgis" }

Options for the request

Returns 

Promise<IQueryFeaturesResponse>

A Promise that will resolve with the query response.

queryFeatures(requestOptions: IQueryFeaturesOptions): Promise<IQueryFeaturesResponse | IQueryResponse>

Query a feature service. See REST Documentation for more information.

Use dark colors for code blocksCopy
1
2
3
4
5
6
import { queryFeatures } from '@esri/arcgis-rest-feature-service';

const response = await queryFeatures({
 url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
 where: "STATE_NAME = 'Alaska'"
});

TypeScript note: return types for queryFeatures() depend on the literal value of f . Inline objects infer literal f values automatically, but pre-declared objects may widen f to string . To preserve a narrow return type for pre-declared objects, use a const assertion, explicit type with a literal declaration, or a satisfies clause.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson" as const
};

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const typedOptions: IQueryFeaturesOptions & { f: "geojson" } = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
};

const typedResponse = await queryFeatures(typedOptions);
// typedResponse is EsriGeoJSONFeatureCollection
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
const options = {
 url: "https://.../FeatureServer/0",
 f: "geojson"
} satisfies IQueryFeaturesOptions;

const response = await queryFeatures(options);
// response is EsriGeoJSONFeatureCollection

Parameters

ParameterTypeNotes
requestOptionsIQueryFeaturesOptions

Options for the request

Returns 

Promise<IQueryFeaturesResponse | IQueryResponse>

A Promise that will resolve with the query response.

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