Learn R Programming

tuber

tuber is an R client for the YouTube Data API and selected YouTube Live Streaming API endpoints. It searches public YouTube data, retrieves channels, videos, playlists, comments, and captions, and supports common authenticated operations such as uploads, comment moderation, and playlist changes.

The package does not wrap every YouTube endpoint. Run vignette("api-conventions", package = "tuber") for the supported resources and known omissions.

Installation

Install the CRAN release:

install.packages("tuber")

Install the development version from GitHub:

# install.packages("pak")
pak::pak("gojiplus/tuber")

Authentication

Public read functions use an API key by default. Create a key in Google Cloud, enable the YouTube Data API v3 for that project, and set the key for the current R session:

yt_set_key("YOUR_YOUTUBE_API_KEY")

OAuth is required for private account data and every operation that changes YouTube data. Create a desktop OAuth client in Google Cloud, then authenticate in the system browser:

yt_oauth("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

yt_oauth() stores its token in the user's R cache directory by default. Pass an explicit token path if you need a different location.

Examples

Search for videos:

videos <- yt_search("Barack Obama", max_results = 25)

Retrieve fixed, snake-case video statistics:

stats <- get_video_stats("N708P-A45D0")

List a channel's playlists and the videos in one playlist:

playlists <- list_playlists(channel_id = "UCMtFAi84ehTSYSE9XoHefig")
items <- list_playlist_items(
  playlist_id = playlists$playlist_id[[1]],
  max_results = 100
)

Collect top-level comments and all replies:

comments <- get_all_comments("a-UQz7fqR3w", max_results = 500)

List and download caption tracks for a video owned by the authenticated account:

tracks <- list_captions("yJXTXN4xrI8")
caption <- download_caption(tracks$caption_id[[1]], as_raw = FALSE)

API conventions

  • list_*() functions mirror YouTube list endpoints and return a data frame by default. Use simplify = FALSE to keep the collected API response.
  • get_*() functions return a derived, enriched, or singular result.
  • Plural ID arguments accept vectors. Singular ID arguments accept one value.
  • max_results is the total result limit, even when the function makes several paginated requests.
  • Fixed simplified schemas use snake-case column names. The columns returned by get_video_details() depend on part and retain YouTube's field names.
  • Public reads default to auth = "key". Functions that can use either form of authentication accept auth = "key" or auth = "token". OAuth-only functions do not expose an auth argument.

License

tuber is released under the MIT License.

Copy Link

Version

Install

install.packages('tuber')

Monthly Downloads

513

Version

2.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Gaurav Sood

Last Published

August 20th, 2026

Functions in tuber (2.0.0)

has_items

Check if object has items
list_live_broadcasts

List live broadcasts
list_languages

List Supported Languages
list_comments

List Comments or Replies
list_live_chat_messages

List Live Chat Messages
list_super_chat_events

List Super Chat Events
list_video_categories

List Video Categories
list_popular_videos

List Most-Popular Videos
list_playlists

List Playlists
list_comment_threads

List Comment Threads
list_channel_sections

List Channel Sections
list_regions

List Supported Content Regions
list_channel_videos

Returns List of Requested Channel Videos
list_subscriptions

List Subscriptions
list_channel_members

List Channel Members
read_sbv

Read SBV file
replace_emojis

Replace emojis in text
paginate_api_request

Paginate API requests with standardized pattern
reply_to_comment

Reply to a Comment
safe_extract

Safely extract field from list/object
%>%

Pipe operator
is_static_query

Check if query parameters indicate static data
remove_emojis

Remove emojis from text
list_my_videos

List My Videos
tuber

tuber provides access to the YouTube API V3.
quota_management

YouTube API Quota Management
post_comment

Post a Top-Level Comment
list_playlist_items

List Playlist Items
safe_nested

Safely extract nested field
tuber_cache_info

Get current cache configuration
summary.tuber_result

Summary method for tuber results
print.tuber_result

Print method for tuber results
quota_cost

Track Quota Usage
tuber_DELETE

DELETE
safe_utf8

Safely Convert Text to UTF-8
tuber_GET

GET
set_comment_moderation_status

Set Comment Moderation Status
search_short_videos

Search for videos shorter than four minutes
tuber_cache_clear

Clear cache entries
tuber_info

Display tuber function metadata
process_youtube_text

Apply Unicode Handling to YouTube API Response
unicode_utils

Unicode and Text Processing Utilities
tuber_POST

POST
store_cached_response

Store response in cache
tuber-package

tuber: Client for the YouTube Data API
tuber_check

Request Response Verification
[.tuber_result

Subset method for tuber results
suggest_solution

Provide helpful suggestions for common user errors
set_video_thumbnail

Set Video Thumbnail
tuber_POST_json

POST encoded in json
tuber_cache_config

Configure caching settings
tuber_PUT

PUT
validate_language_code

Validate language codes
warn_deprecated

Warn about deprecated functionality with migration guidance
validate_max_results

Validate YouTube-specific IDs and parameters
upload_video

Upload Video to Youtube
utils

Tuber Utility Functions
validate_filter

Validate filter parameter for YouTube API functions
validate_part_parameter

Validate YouTube API part parameters
validate_channel_id

Validate YouTube channel ID format
yt_oauth

Set up Authorization
update_video_metadata

Update Video Metadata
upload_caption

Upload a Caption Track
yt_reset_quota

Reset Quota Counter
validate_playlist_id

Validate YouTube playlist ID format
validate_region_code

Validate region codes
validate_youtube_params

Comprehensive parameter validation for YouTube API functions
with_retry

Exponential backoff retry logic for API calls
yt_get_quota_usage

Get Current Quota Usage
yt_token

Check if authentication token is in options
yt_key

Manage YouTube API key
validate_rfc3339_date

Validate RFC 3339 date format for YouTube API
validate_video_id

Validate YouTube video ID format
yt_search

Search YouTube
yt_set_quota_limit

Set Quota Limit
EMOJI_PATTERN

Emoji Unicode Pattern
analyze_trends

Trending analysis for search terms
analyze_channel

Comprehensive channel analysis
add_video_to_playlist

Add Video to Playlist
bulk_video_analysis

Bulk video performance analysis
delete_caption

Delete a Caption Track
count_emojis

Count emojis in text
create_playlist

Create New Playlist
compare_channels

Compare multiple channels
delete_playlist_item

Delete a Playlist Item
delete_playlist

Delete a Playlist
get_all_comments

Get All Video Comments, Including Replies
extended-endpoints

Extended YouTube API Endpoints
delete_comment

Delete a Comment
delete_channel_section

Delete a Channel Section
get_all_channel_video_stats

Get statistics on all the videos in a Channel
handle_http_response

Handle HTTP response for quota and rate limiting errors
clean_youtube_text

Clean and Normalize YouTube Text Data
generate_cache_key

Generate cache key for API request
call_api_with_retry

Wrapper for tuber API calls with built-in retry logic
caching

Response Caching for YouTube API
build_comment_row

Build a standardized comment data frame row
build_httr2_request

Build httr2 request for YouTube API
change_playlist_title

Change a Playlist Title
delete_video

Delete a Video
get_video_thumbnails

Get video thumbnails information
has_emoji

Detect emojis in text
get_video_stats

Get Video Statistics
extract_emojis

Extract emojis from text
get_playlist_item_ids

Get Playlist-Item IDs
get_video_details

Get Video Details
get_cached_response

Get cached response if available and valid
error-handling

Tuber Error Handling Utilities
add_tuber_attributes

Add standardized metadata attributes to API response
get_channel_details

Get Channel Details
get_video_broadcast_timing

Get video live-broadcast timing
download_caption

Download a Caption Track
list_abuse_report_reasons

List Video-Abuse Report Reasons
helper-functions

Helper Functions for Common YouTube Analysis Tasks
handle_network_error

Handle network/connection errors with retry suggestions
get_playlist_video_ids

Get Video IDs from a Playlist
list_captions

List Caption Tracks
list_channel_activities

List Channel Activities
insert_channel_banner

Insert Channel Banner
is_transient_error

Check if an error is transient and worth retrying
is_cacheable_endpoint

Check if endpoint should be cached
exponential_backoff

Add Exponential Backoff
handle_api_error

Handle YouTube API errors with context-specific messages