Parameters
The unique identifier of the dataset.At least one of
dataset_id or resource_id must be provided. Can be used alone or together with resource_id.The unique identifier of the resource.At least one of
dataset_id or resource_id must be provided. Can be used alone or together with dataset_id.Number of monthly records to return.Minimum: 1, Maximum: 100. Results are sorted by month in descending order (most recent first).
Returns
Returns a formatted text response containing:For dataset metrics:
- Dataset title and ID
- Monthly statistics table:
- Month (YYYY-MM format)
- Visits count
- Downloads count
- Total visits and downloads across all returned months
For resource metrics:
- Resource title and ID
- Monthly statistics table:
- Month (YYYY-MM format)
- Downloads count
- Total downloads across all returned months
Usage notes
Environment requirement
The tool checks theDATAGOUV_API_ENV environment variable:
- ✅
prod(or unset): Metrics are available - ❌
demo: Returns error message
What metrics are tracked
Dataset metrics include:- Visits: Page views of the dataset page on data.gouv.fr
- Downloads: Total downloads of all resources in the dataset
- Downloads: Downloads of this specific resource file
Metrics sorting
Metrics are always returned sorted by month in descending order (most recent first):Using both parameters
You can provide bothdataset_id and resource_id to get metrics for both in a single call. The tool will return two separate sections in the response.
Error handling
The tool handles the following error cases:- Demo environment: Returns error message explaining Metrics API is only available in production
- No parameters: Returns error if neither
dataset_idnorresource_idis provided - Empty IDs: Returns error if provided IDs are empty strings
- Not found: Returns appropriate error if dataset/resource doesn’t exist
- Metadata fetch failures: Continues with “Unknown” title if metadata cannot be fetched
- Metrics fetch failures: Returns error message with details
Example workflows
Get dataset metrics
Get resource metrics
Get both dataset and resource metrics
Historical analysis
Typical use cases
- Popularity analysis: Identify most visited/downloaded datasets
- Trend analysis: Track usage patterns over time
- Impact assessment: Measure dataset reach and adoption
- Resource comparison: Compare download counts between resources in a dataset
- Reporting: Generate usage reports for stakeholders