The Tilequery class provides access to the Mapbox Tilequery API. You can import it from either the mapbox module or the mapbox.services.tilequery module.


>>> from mapbox import Tilequery


>>> from mapbox.services.tilequery import Tilequery

See https://www.mapbox.com/api-documentation/#tilequery for general documentation of the API.

Use of the Tilequery API requires an access token, which you should set in your environment. For more information, see the access tokens documentation.

Tilequery Method

The public method of the Tilequery class provides access to the Tilequery API and returns an instance of requests.Response.

Usage: Retrieving Features

Instantiate Tilequery.

>>> tilequery = Tilequery()

Call the tilequery method, passing in values for map_id, lon, and lat. Pass in values for optional arguments as necessary - radius, limit, dedupe, geometry, and layers.

>>> response = tilequery.tilequery("mapbox.mapbox-streets-v8", lon=0.0, lat=1.1)

Evaluate whether the request succeeded, and retrieve the features from the response object.

>>> if response.status_code == 200:
...     features = response.json()