Method: videos.batchGetStats

Retrieves a batch of video statistics for the specified video IDs. This method isn't atomic; invalid, missing, or inaccessible video IDs are omitted from items rather than failing the batch.

Authorization: Public video queries work with an API key. OAuth 2.0 authorization is required for non-public videos and onBehalfOfContentOwner.

Quota impact: A call to this method uses the dedicated Video Batch Get Stats quota bucket (1 unit per call, with default limits of 10,000 calls per day and 600 calls per minute per project).

For error responses, see YouTube Data API errors.

HTTP request

GET https://youtube.googleapis.com/youtube/v3/videos:batchGetStats

The URL uses gRPC Transcoding syntax.

Query parameters

Parameters
id[]

string

Required. Specifies a comma-separated list (or repeated query parameters) of YouTube video IDs. The number of IDs specified can't exceed 50. Invalid or inaccessible video IDs are omitted from items.

part[]

string

Required. Specifies a comma-separated list of one or more videoStat resource properties that the API response includes.

Valid values are contentDetails, id, snippet, and statistics.

onBehalfOfContentOwner

string

Optional. Indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter can only be used in a properly authorized request and is intended exclusively for YouTube content partners.

It allows content owners that own and manage multiple YouTube channels to authenticate once and access their video and channel data without providing separate authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.

Request body

The request body must be empty.

Response body

Returns video statistics for the requested videos.

If successful, the response body contains data with the following structure:

JSON representation
{
  "kind": string,
  "etag": string,
  "items": [
    {
      "etag": string,
      "id": string,
      "snippet": {
        "publishTime": string
      },
      "statistics": {
        "viewCount": string,
        "likeCount": string,
        "commentCount": string
      },
      "contentDetails": {
        "duration": string
      }
    }
  ]
}
Fields
kind

string

Identifies what kind of resource this is. Value: the fixed string "youtube#batchGetStatsResponse".

etag

string

Etag of this resource.

items[]

object

The videos' stats information.

items[].etag

string

Output only. Etag of this resource.

items[].id

string

Output only. The ID that YouTube uses to uniquely identify the video.

items[].snippet

object

Output only. The VideoStatsSnippet object contains basic details about the video, such as publish time.

items[].snippet.publishTime

string (Timestamp format)

Output only. The date and time that the video was published (or uploaded, if never published).

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

items[].statistics

object

Output only. The VideoStatsStatistics object contains statistics about the video.

items[].statistics.viewCount

string (int64 format)

Output only. The number of times the video has been viewed.

For all video formats (long-form, Live, and Shorts), viewCount includes co-views when multiple people watch together on a television screen.

items[].statistics.likeCount

string (int64 format)

Output only. The number of users who have indicated that they liked the video by giving it a positive rating.

items[].statistics.commentCount

string (int64 format)

Output only. The number of comments for the video.

items[].contentDetails

object

Output only. The VideoStatsContentDetails object contains information about the video content, including the length of the video.

items[].contentDetails.duration

string (Duration format)

Output only. The length of the video.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/youtube
  • https://www.googleapis.com/auth/youtubepartner
  • https://www.googleapis.com/auth/youtube.readonly
  • https://www.googleapis.com/auth/youtube.force-ssl

For more information, see the OAuth 2.0 Overview.