VideosApi
extends AbstractApi
in package
This file is generated from spec/discovery.json (YouTube Data API v3, revision 20260924) by tools/generate.php. Do not edit it by hand - run `composer spec:build` instead.
Videos: listing, uploading, updating, rating and reporting them.
Reach it as $youtube->videos. Every method takes the parameters Google
documents, by the same names: use named arguments for the optional ones.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- batchGetStats() : PromiseInterface<string|int, BatchGetStatsResponse>
- Retrieves a batch of VideoStat resources, possibly filtered. BatchGetStats is intentionally not atomic to provide a better user experience.
- delete() : PromiseInterface<string|int, null>
- Deletes a resource.
- getRating() : PromiseInterface<string|int, VideoGetRatingResponse>
- Retrieves the ratings that the authorized user gave to a list of specified videos.
- insert() : PromiseInterface<string|int, Video>
- Inserts a new resource into this collection.
- list() : PromiseInterface<string|int, VideoListResponse>
- Retrieves a list of resources, possibly filtered.
- rate() : PromiseInterface<string|int, null>
- Adds a like or dislike rating to a video or removes a rating from a video.
- reportAbuse() : PromiseInterface<string|int, null>
- Report abuse for a video.
- update() : PromiseInterface<string|int, Video>
- Updates an existing resource.
- call() : PromiseInterface<string|int, mixed>
- streamed() : PromiseInterface<string|int, ResponseStream>
- Opens a server-streamed call and reads its body as it arrives.
Properties
$youtube read-only
protected
YouTube
$youtube
Methods
__construct()
public
__construct(YouTube $youtube) : mixed
Parameters
- $youtube : YouTube
batchGetStats()
Retrieves a batch of VideoStat resources, possibly filtered. BatchGetStats is intentionally not atomic to provide a better user experience.
public
batchGetStats([array<int, string>|string|null $id = null ][, string|null $onBehalfOfContentOwner = null ][, array<int, string>|string|null $part = null ]) : PromiseInterface<string|int, BatchGetStatsResponse>
Costs 1 unit of quota.
Parameters
- $id : array<int, string>|string|null = null
-
Required. Return videos with the given ids. The number of IDs specified cannot exceed 50.
- $onBehalfOfContentOwner : string|null = null
-
Optional. Note: This parameter is intended exclusively for YouTube content partners. The
onBehalfOfContentOwnerparameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. - $part : array<int, string>|string|null = null
-
Required. The
**part**parameter specifies a comma-separated list of one or morevideoStatresource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in avideoStatresource, thestatisticsproperty containsview_countandlike_count. As such, if you set**part=snippet**, the API response will contain all of those properties.
Tags
Return values
PromiseInterface<string|int, BatchGetStatsResponse>delete()
Deletes a resource.
public
delete(string $id[, string|null $onBehalfOfContentOwner = null ]) : PromiseInterface<string|int, null>
Costs 50 units of quota.
Parameters
- $id : string
- $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner.
Tags
Return values
PromiseInterface<string|int, null>getRating()
Retrieves the ratings that the authorized user gave to a list of specified videos.
public
getRating(array<int, string>|string $id[, string|null $onBehalfOfContentOwner = null ]) : PromiseInterface<string|int, VideoGetRatingResponse>
Costs 1 unit of quota.
Parameters
- $id : array<int, string>|string
- $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.
Tags
Return values
PromiseInterface<string|int, VideoGetRatingResponse>insert()
Inserts a new resource into this collection.
public
insert(array<int, string>|string $part, Video|array<string, mixed> $body[, Media|null $media = null ][, bool|null $autoLevels = null ][, bool|null $notifySubscribers = null ][, string|null $onBehalfOfContentOwner = null ][, string|null $onBehalfOfContentOwnerChannel = null ][, bool|null $stabilize = null ]) : PromiseInterface<string|int, Video>
Costs 1 of the uploads quota's 100 calls a day, not the shared daily quota.
Parameters
- $part : array<int, string>|string
-
The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that not all parts contain properties that can be set when inserting or updating a video. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response.
- $body : Video|array<string, mixed>
-
The Video to send.
- $media : Media|null = null
-
The file to upload: video/*, application/octet-stream, up to 256 GB. Sent in the same request as the metadata.
- $autoLevels : bool|null = null
-
Should auto-levels be applied to the upload.
- $notifySubscribers : bool|null = null
-
Notify the channel subscribers about the new video. As default, the notification is enabled. YouTube assumes
truewhen it is left out. - $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.
- $onBehalfOfContentOwnerChannel : string|null = null
-
This parameter can only be used in a properly authorized request. Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel.
- $stabilize : bool|null = null
-
Should stabilize be applied to the upload.
Tags
Return values
PromiseInterface<string|int, Video>list()
Retrieves a list of resources, possibly filtered.
public
list(array<int, string>|string $part[, string|null $chart = null ][, string|null $hl = null ][, array<int, string>|string|null $id = null ][, string|null $locale = null ][, int|null $maxHeight = null ][, int|null $maxResults = null ][, int|null $maxWidth = null ][, string|null $myRating = null ][, string|null $onBehalfOfContentOwner = null ][, string|null $pageToken = null ][, string|null $regionCode = null ][, string|null $videoCategoryId = null ]) : PromiseInterface<string|int, VideoListResponse>
Costs 1 unit of quota.
Parameters
- $part : array<int, string>|string
-
The part parameter specifies a comma-separated list of one or more video resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a video resource, the snippet property contains the channelId, title, description, tags, and categoryId properties. As such, if you set part=snippet, the API response will contain all of those properties.
- $chart : string|null = null
-
Return the videos that are in the specified chart. One of
chartUnspecified,mostPopular. - $hl : string|null = null
-
Stands for "host language". Specifies the localization language of the metadata to be filled into snippet.localized. The field is filled with the default metadata if there is no localization in the specified language. The parameter value must be a language code included in the list returned by the i18nLanguages.list method (e.g. en_US, es_MX).
- $id : array<int, string>|string|null = null
-
Return videos with the given ids.
- $locale : string|null = null
-
Deprecated.
- $maxHeight : int|null = null
-
From 72 to 8192.
- $maxResults : int|null = null
-
The maxResults parameter specifies the maximum number of items that should be returned in the result set. Note: This parameter is supported for use in conjunction with the myRating and chart parameters, but it is not supported for use in conjunction with the id parameter. From 1 to 50. YouTube assumes
5when it is left out. - $maxWidth : int|null = null
-
Return the player with maximum height specified in From 72 to 8192.
- $myRating : string|null = null
-
Return videos liked/disliked by the authenticated user. Does not support RateType.RATED_TYPE_NONE. One of
none,like,dislike. - $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.
- $pageToken : string|null = null
-
The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. Note: This parameter is supported for use in conjunction with the myRating and chart parameters, but it is not supported for use in conjunction with the id parameter.
- $regionCode : string|null = null
-
Use a chart that is specific to the specified region
- $videoCategoryId : string|null = null
-
Use chart that is specific to the specified video category YouTube assumes
0when it is left out.
Tags
Return values
PromiseInterface<string|int, VideoListResponse>rate()
Adds a like or dislike rating to a video or removes a rating from a video.
public
rate(string $id, string $rating) : PromiseInterface<string|int, null>
Costs 50 units of quota.
Parameters
- $id : string
- $rating : string
-
One of
none,like,dislike.
Tags
Return values
PromiseInterface<string|int, null>reportAbuse()
Report abuse for a video.
public
reportAbuse(VideoAbuseReport|array<string, mixed> $body[, string|null $onBehalfOfContentOwner = null ]) : PromiseInterface<string|int, null>
Costs 50 units of quota.
Parameters
- $body : VideoAbuseReport|array<string, mixed>
-
The VideoAbuseReport to send.
- $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner.
Tags
Return values
PromiseInterface<string|int, null>update()
Updates an existing resource.
public
update(array<int, string>|string $part, Video|array<string, mixed> $body[, string|null $onBehalfOfContentOwner = null ]) : PromiseInterface<string|int, Video>
Costs 50 units of quota.
Parameters
- $part : array<int, string>|string
-
The part parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. For example, a video's privacy setting is contained in the status part. As such, if your request is updating a private video, and the request's part parameter value includes the status part, the video's privacy setting will be updated to whatever value the request body specifies. If the request body does not specify a value, the existing privacy setting will be removed and the video will revert to the default privacy setting. In addition, not all parts contain properties that can be set when inserting or updating a video. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response.
- $body : Video|array<string, mixed>
-
The Video to send.
- $onBehalfOfContentOwner : string|null = null
-
Note: This parameter is intended exclusively for YouTube content partners. The onBehalfOfContentOwner parameter 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 is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner.
Tags
Return values
PromiseInterface<string|int, Video>call()
protected
call(string $endpoint, string $method, string $path[, array<string, mixed> $query = [] ][, array<string, mixed>|JsonSerializable|null $body = null ][, string|null $returns = null ][, ?Media $media = null ][, ?string $uploadPath = null ][, bool $download = false ]) : PromiseInterface<string|int, mixed>
Parameters
- $endpoint : string
-
The API method, e.g.
liveChatMessages.list. - $method : string
- $path : string
- $query : array<string, mixed> = []
- $body : array<string, mixed>|JsonSerializable|null = null
- $returns : string|null = null
-
The type token the result hydrates as; null leaves it raw.
- $media : ?Media = null
- $uploadPath : ?string = null
- $download : bool = false
Return values
PromiseInterface<string|int, mixed>streamed()
Opens a server-streamed call and reads its body as it arrives.
protected
streamed(string $endpoint, string $path, array<string, mixed> $query, string $returns) : PromiseInterface<string|int, ResponseStream>
Parameters
- $endpoint : string
- $path : string
- $query : array<string, mixed>
- $returns : string
-
The type token each element hydrates as.