View source: R/get_channel_stats.R
| get_channel_stats | R Documentation |
Get statistics and details for one or more YouTube channels efficiently using batch processing.
get_channel_stats(
channel_ids = NULL,
mine = NULL,
part = c("statistics", "snippet"),
simplify = TRUE,
batch_size = 50,
show_progress = NULL,
auth = "token",
...
)
list_my_channel(...)
channel_ids |
Character vector of channel IDs to retrieve. Use |
mine |
Logical. Set to TRUE to get authenticated user's channel.
Overrides |
part |
Character vector of parts to retrieve. Default: c("statistics", "snippet"). |
simplify |
Logical. If TRUE (default), returns a data frame. If FALSE, returns raw list. |
batch_size |
Number of channels per API call (max 50). Default: 50. |
show_progress |
Whether to show progress for large batches. Default: TRUE for >10 channels. |
auth |
Authentication method: "token" (OAuth2) or "key" (API key). Default: "token". |
... |
Additional arguments passed to |
Valid parts include: auditDetails, brandingSettings, contentDetails,
contentOwnerDetails, id, localizations, snippet, statistics, status,
topicDetails.
The function automatically batches requests to minimize API quota usage: - 1 channel = 1 API call - 100 channels = 2 API calls (batched in groups of 50)
When simplify = TRUE (default): Data frame with channel details.
When simplify = FALSE: List with channel details.
For single channels, returns the channel object directly (not in a list). For multiple channels, returns a list with items array.
https://developers.google.com/youtube/v3/docs/channels/list
## Not run:
# Get stats for a single channel - displays console output
stats <- get_channel_stats("UCT5Cx1l4IS3wHkJXNyuj4TA")
# Get stats for multiple channels - automatically batched
channel_ids <- c("UCT5Cx1l4IS3wHkJXNyuj4TA", "UCfK2eFCRQ64Gqfrpbrcj31w")
stats <- get_channel_stats(channel_ids)
# Get as data frame
df <- get_channel_stats(channel_ids, simplify = TRUE)
# Get your own channel stats
my_stats <- get_channel_stats(mine = TRUE)
# Get additional parts
detailed <- get_channel_stats(channel_ids,
part = c("statistics", "snippet", "brandingSettings"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.