Skip to content

Get Layer Attribute Values

The attribute values endpoint provides a preview of possible values for a specific attribute (field) of a given vector layer. This is useful for building filter UIs, dropdowns, or for understanding the data distribution in a layer. This endpoint can be used to get more detailed information about possible attribute values.

https://api3.geo.admin.ch/rest/services/api/MapServer/{layerBodId}/attributes/{attributeName}

Request Details

To interact with the Layer Attribute Values service, you need to provide specific parameters in your request. This endpoint only has Path Parameters which are mandatory.

Path Parameters

ParametersDescription
layerBodId (required)The technical name or the layer ID.
attributeName (required)The name of the attribute for which to retrieve values.

Response Details

The endpoint returns a JSON with information about the attribute values for the specified layer and attribute. The response includes an array of values. For attributes of type DATE, INTEGER, NUMERIC the endpoint returns the minimum and maximum values as a two-element array. For other attribute types the endpoint returns up to 50 distinct values, sorted.

Here is a description of the data contained in the response.

FieldDescription
valuesArray of attribute values

Examples

Get distinct values for the egid attribute from layer ch.bfs.gebaeude_wohnungs_register:

Request
Response
sh
curl https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/attributes/egid

Get the min and max value for the garea attribute from layer ch.bfs.gebaeude_wohnungs_register with descending order:

Request
Response
sh
curl "https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/attributes/garea"