Custom analytics query
query_analyticsRun custom YouTube Analytics API v2 reports for your channel with selected metrics, dimensions, filters, date ranges, sorting, and row limits when preset reports do not fit.
Instructions
Run any YouTube Analytics API v2 report for the channel (ids=channel==MINE) — the escape hatch when no other tool fits. See https://developers.google.com/youtube/analytics/channel_reports for valid combinations. Notes: the 'video' dimension needs sort and max_results <= 200; 'insightTrafficSourceDetail' needs a filter on insightTrafficSourceType, sort and max_results <= 25; demographics (ageGroup/gender) only support viewerPercentage; the 'month' dimension aligns dates to whole months automatically. YouTube's error message is returned if a combination is invalid.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"metrics": "<metrics>"
},
"name": "query_analytics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sort | No | Comma-separated sort, '-' for descending, e.g. '-views'. | |
| period | No | Named date range, Studio-style. Rolling ranges end at the latest complete day of data (analytics lag ~2-3 days; dates are US Pacific). Ignored when start_date is set. | last_28_days |
| filters | No | Analytics filter string, e.g. 'video==ID1,ID2;country==US' (';' = AND). | |
| metrics | Yes | Metric API names, e.g. ['views', 'likes']. | |
| save_to | No | Optional file to also save the rows to (.csv or .json). A bare filename goes in the output directory; absolute paths are allowed. | |
| currency | No | Currency for revenue metrics (ISO 4217). | |
| end_date | No | Custom range end, YYYY-MM-DD (inclusive). Defaults to the latest complete day. | |
| dimensions | No | Dimension API names, e.g. ['day'], ['video'], ['country', 'creatorContentType']. | |
| start_date | No | Custom range start, YYYY-MM-DD. Overrides `period`. | |
| max_results | No | Row limit. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||