Is there any way to get the videos from autogenerated channels (like this one https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/videos) directly, without having to access all the playlists?
Using https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&key=... gives me 0 items.
Gives me 0 Items
If you mean running the following exactly
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&key=
Returns the following error
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
That is because you have neglected to add an API key on the end.
Try testing in the query explorer this seams to return quite a few no idea if its all of them.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&maxResults=25&key={YOUR_API_KEY}
returns
"pageInfo": {
"totalResults": 786,
"resultsPerPage": 25
},
This apears to return a list of the playlists only for this user.
Update:
If you try and only request videos for this user you get 0 returned. This is not the case for any other user which i have tested.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&maxResults=50&order=date&type=video&key={YOUR_API_KEY}
This leads me to believe that it is not possible to retrieve the videos for an autogenerated channel. I recommend either logging this as a bug or adding it as a feature request here. Personally i think its more a feature request.
Related
I'm building an app that based on user's choice connects to youtube api and get's list of videos of certain playlist.
I would like to make it safe to use and if the status is not 200, make it impossible for the next screen to show.
The JSON result from my request does not return any information on the status other than privacy status (similarly, if I get data for a video not a playlist I get detailed information) :
var urlString = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=500&playlistId=\(playlistId)&key=XXXXX"
"status":{
"privacyStatus":"public"
}
How do I verify that the request for the playlist is valid?
Thanks!
I have not found a reliable way to test the YT api status, so I generally will look for results from the call that should be there. And if they are not there (i.e. empty or '0' ) , then it is normally a failed call.
So [totalResults] and/or [title] as example.
There are two parts here.
You need to determine if the actual HTTP request was successful or not (that is the request to https://googleapis/youtube/v3/[method]?[parameters])
You have a specific requirement where you need to handle cases where there is no data. The response from the API itself will not explicitly provide this to you, instead you need to define what failure means.
With this in mind, you could implement two levels of checks:
Check 1 - HTTP status code
The first level would check the HTTP status code (200 = OK, 400 = Bad Request, etc.).
If your API request returns a status of 200, you can move on to the next level of checks (see Check 2). However, if your API request returns a status of 400, then the request has failed and no further checks are required (or necessary).
Note: If you do get a 400 status, there is some JSON in the response which contains detailed information regarding the error.
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"message": "No filter selected. Expected one of: id, playlistId",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "No filter selected. Expected one of: id, playlistId"
}
}
Check 2 - Data
The second level would check to see if any results have been returned (as it seems possible to have a HTTP status code of 200 and no results).
This has nothing to do with the status of the actual HTTP request itself. Instead you have to check the response to see if the data you application requires is present or not.
With the example of a 200 response below, the items array is empty. So you could say that even though the request was successful, this is a failure condition and not show your next screen.
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"[etag would appear here]\"",
"nextPageToken": "CAAQAA",
"pageInfo": {
"totalResults": 199,
"resultsPerPage": 0
},
"items": [
]
}
Note: The above is an example where the results per page was purposely set to 0.
I'm having trouble finding a way to access comments from a youtube video.
The closest thing I came across told me that that feature was a google+ only api call.
using
https://developers.google.com/youtube/v3/docs/comments/list#try-it
i get
SHOW HEADERS -
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "operationNotSupported",
"message": "The id filter is only compatible with comments based on Google+.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The id filter is only compatible with comments based on Google+."
}
}
You can use CommentThreads:list which returns a list of all comments threads that match the API request parameters.
HTTP request
GET https://www.googleapis.com/youtube/v3/commentThreads
If the response is successfull, method returns a response body with the following structure:
{
"kind": "youtube#commentThreadListResponse",
"etag": etag,
"nextPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
commentThread Resource
]
}
Here's a YouTube API sample code with different supported programming languages: https://developers.google.com/youtube/v3/docs/commentThreads/list#examples
Found this Stack Overflow related ticket, discuss how to get comments through YouTube API: How to get comments through Youtube Data API v3 / JSOUP parsing?
I want to get list of videos of a particular YouTube channel.
I followed this SO answer https://stackoverflow.com/a/20795628/5383573
Every time I am getting
400 Bad Request
Suppose I want to get all the video of NDTV Channel.
Its YouTube url is https://www.youtube.com/user/ndtv/videos
I went to this URL https://developers.google.com/youtube/v3/docs/playlists/list
Fill the boxes as
Part: NDTV
Channel ID:ndtv
Max Result: 50
and click Execute
It gives me Request as
GET https://www.googleapis.com/youtube/v3/playlists?part=ndtv&channelId=ndtv&maxResults=50&key={YOUR_API_KEY}
And response
400 Bad Request
{
"error": {
"errors": [
{
"domain": "youtube.part",
"reason": "unknownPart",
"message": "ndtv",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "ndtv"
}
}
How can I get all the videos in JSON response?
Sorry for my bad English.
Any help will be appreciated.Thanks in advance
Playlists: list has five valid parts
The list below contains the part names that you can include in the
parameter value and the quota cost for each part: contentDetails: 2
id: 0 player: 0 snippet: 2 status: 2
A your error message states ndtv is not valid part. NDTV is also not a valid channel id. A channel id looks like this UCtb0gXU-ht24V_fgeXGGjwA
The easest way tof ind the channel id is to check YouTube
https://www.youtube.com/channel/UCtb0gXU-ht24V_fgeXGGjwA
NDTV has 3 featured channels, those with channel_id
UCZFMm1mMw0F81Z37aaEzTUA,UC9CYT9gSNLevX5ey2_6CK0Q,UCf9StUUEcbRpbvpdKx5eS_g
The following GET requests will return json response.
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId={ndtv_channel_id}
replace ndtv_channel_id with the channel id.
I want to get more than 50 youtube video results corresponding to topic id ........so i am trying to get next page token.......
in youtube api v3 in android
and url used is....
https://www.googleapis.com/youtube/v3/videos?part=id,snippet&order=relevancee&topicId="+topicId+"&q="+videoId+"&key="
but the error giving is......
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "missingRequiredParameter",
"message": "No filter selected.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "No filter selected."
}
}
You should set type = video
Whenever you are using a video specific filter you have to filter type as well. As search is unified, otherwise it normally returns playlist, channel and videos as a result.
You can always try your queries in API explorer before implementing.
I am getting invalid combination of search filter error while retrieving the HD videos. this was the url - https://www.googleapis.com/youtube/v3/search?part=snippet&q=drama&videoDefinition=high&key={Developerkey}
Error report
{
"error": {
"errors": [
{
"domain": "youtube.search",
"reason": "invalidSearchFilter",
"message": "Invalid combination of search filters and/or restrictions.",
"locationType": "parameter",
"location": ""
}
],
"code": 400,
"message": "Invalid combination of search filters and/or restrictions."
}
}
Is it possible to retrieve HD videos? Please guide me. How can I get a response from this URL? Thanks
You also need to include the type=video query parameter, since filtering on high definition only makes sense when the results are limited to videos.
That being said, the error message that's returned isn't actually helpful, and I'll ask the engineering team to revise it so that it clarifies what's wrong.