Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Latest commit

 

History

History
41 lines (25 loc) · 1.21 KB

analytics.md

File metadata and controls

41 lines (25 loc) · 1.21 KB

Analytics

The Analytics class from the mapbox.services.analytics module provides access to the Mapbox Analytics API. You can also import it directly from the mapbox module.

Note: This API is available only for premium and enterprise plans.

>>> from mapbox import Analytics

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

Your Mapbox access token should be set in your environment; see the access tokens documentation for more information.

Analytics methods

The methods of Analytics class that provide access to the Analytics API return an instance of requests.Response. Analytics response also include the json() method which returns Python data parsed from API.

Usage

The Mapbox Analytics API is used to get API usage for services by resource. It returns counts per day for given resource and period.

>>> analytics = Analytics()

The input to analytics method are resource_type, username, id, period, access_token.

>>> response = analytics.analytics('accounts', 'mapbox-sdk-py-user')
>>> response.status_code
200