get_report: Get Reports

View source: R/get_report.R

get_reportR Documentation

Get Reports

Description

Retrieves YouTube Analytics reports containing YouTube Analytics data.

Usage

get_report(
  ids,
  metrics,
  start_date = NULL,
  end_date = NULL,
  currency = NULL,
  dimensions = NULL,
  filters = NULL,
  include_historical_channel_data = NULL,
  max_results = NULL,
  sort = NULL,
  start_index = NULL,
  ...
)

Arguments

ids

String. Channel or content owner identifier. For channels: "channel==MINE" (for authenticated user's channel) or "channel==UCxxxxxxxxxxxxxxx" (for specific channel ID). For content owners: "contentOwner==ownerName".

metrics

String. Comma-separated list of YouTube Analytics metrics, such as views or likes,dislikes.

start_date

String. Start date for the report. Can be in YYYY-MM-DD format or relative date like "last_30_days", "this_month", "yesterday".

end_date

String. End date for the report. Can be in YYYY-MM-DD format or relative date. If NULL and start_date is relative, will be calculated automatically.

currency

Optional. String. Default is USD. Specifies what earnings metrics like earnings, adEarnings, grossRevenue, playbackBasedCpm, impressionBasedCpm will be reported in.

dimensions

String. Optional. Comma-separated list of YouTube Analytics dimensions, such as video or ageGroup,gender.

filters

String. Optional. Dimension value filters. Multiple filters can be separated by semicolons. For video filtering: "video==videoId1,videoId2" (comma-separated video IDs). For country filtering: "country==US". Combined example: "video==videoId1,videoId2;country==US". Note: When filtering by video IDs, ensure the dimensions parameter includes "video".

include_historical_channel_data

Boolean. Default is FALSE. “Whether the API response should include channels' watch time and view data from the time period prior to when the channels were linked to the content owner.”

max_results

Integer. Optional. The maximum number of rows to include in the response.

sort

String. Optional A comma-separated list of dimensions or metrics that determine the sort order for YouTube

start_index

Integer. Optional. “The 1-based index of the first entity to retrieve.”

...

Additional arguments passed to tubern_GET.

Value

named list

Troubleshooting 404 Errors

If you encounter a 404 "Not Found" error, check the following:

  • Ensure YouTube Analytics API is enabled in your Google Cloud Console project

  • Verify your authentication token is valid and has the correct scopes

  • Check that the channel ID (if using specific channel ID) exists and you have access to it

  • Use "channel==MINE" to access your own authenticated channel's data

References

https://developers.google.com/youtube/analytics/reference/reports/query

Examples

## Not run: 
# Basic channel report
get_report(ids = "channel==MINE", metrics = "views",
           start_date = "2020-01-01", end_date = "2020-01-31")

# Report with video filtering (requires dimensions = "video")
get_report(ids = "channel==MINE",
           metrics = "views,likes,comments",
           dimensions = "video",
           filters = "video==videoId1,videoId2",
           start_date = "2020-01-01", end_date = "2020-01-31")

# Report with country filtering
get_report(ids = "channel==MINE",
           metrics = "views",
           filters = "country==US",
           start_date = "2020-01-01", end_date = "2020-01-31")

## End(Not run)

tubern documentation built on April 12, 2026, 5:07 p.m.