I do this YouTube API call to retrieve the user videos list.
https://www.googleapis.com/youtube/v3/search?access_token=secret&part=id,snippet&type=video&forMine=true&maxResults=50&order=date
It works great except that it won't return the prevPageToken param.
I know this param is not return on the first page, but my problem here is that it is NEVER returned.
The nextPageToken param works as expected and is always returned.
I tried to remove the order/maxResults params but it did not change anything.
Am I missing something here ?
According to the documentation it should be there. Maybe file it as a bug here: https://code.google.com/p/gdata-issues/issues/list?q=label%3aAPI-YouTube. Check first that it has not been filed already.
I just tried. I do get a prevPageToken for:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=5&pageToken=CAUQAA&q=cover&type=video&key={YOUR_API_KEY}
See Response:
{
"kind": "youtube#searchListResponse",
"etag": "\"bvxF-DWHx1toJotsdJBeCm43SLs/j02ylGuod7b8YA4wvEAk8TsyYjU\"",
"nextPageToken": "CAoQAA",
"prevPageToken": "CAUQAQ",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 5
},
"items": [.....
}
And using the value for prevPageToken as pageToken is also working: getting the previous page.
Make sure setFields parameter has prevPageToken set
search.setFields("items(id/kind,id/videoId),nextPageToken,prevPageToken");
Related
So I am using the smiirl counter and was hoping to not have to try and scrub data after the fact instead just use google api directly... i got as far as this example below but it looks like it wont work for me if items and statistics are included, no attributes are identified for me to use in the smiirl interface...i literally can only have 1 line with subscribercount on it...is there a direct way to dig that deep?
currently getting
{
"items": [
{
"statistics": {
"subscriberCount": "3"
}
}
]
}
what i need
{
"subscriberCount": "3"
}
You appear to be using the Channels: list method.
The response returned by this method is
{
"kind": "youtube#channelListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
channel Resource
]
}
You can use the fields optional parameter to reduce the fields returned. which i suspect you are already doing something like this.
FieldMask used for response filtering. If empty, all fields should be returned unless documented otherwise.
fields = items(statistics(subscriberCount))
That is the best your going to be able to get. You can not change the format of a response from an api endpoint.
May i suggest creating a method on your end that when the data is returned reformat it locally
Using the youtube API, I get no results for either channels list, search, ... for a channel where there is some content.
There is no error returned, just an empty set. No channels, no video, nothing either in the API explorer or through my code.
Everything was working correctly up until a few days/weeks (hard to tell when since I had no errors)
curl -v 'https://www.googleapis.com/youtube/v3/search?key=[api_key]&channelId=UCKTgGP9lrL5Yjs4f8WuI1Vw&part=snippet,id&order=date&maxResults=20'
is the query I used but I tried to get the uploads channel id as some answers here advised but the channels/list endpoint is empty too. I checked the documentation and I couldn't find anything wrong with my query.
This is the answer I currently get:
{
"kind": "youtube#searchListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/nrqzXB-_ht29Bt6u-f7_lLyFcCw\"",
"regionCode": "BE",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 20
},
"items": []
}
and you can see here https://www.youtube.com/channel/UCKTgGP9lrL5Yjs4f8WuI1Vw/videos that it's not empty.
Try to add type=video as param, it seems working :)
Update: It was a bug, now fixed.
Searching youtube comments API with searchTerms=someKeywords and order=relevance doesn't return results, but when setting order=time it works, any idea why?
Sample API Request:
https://www.googleapis.com/youtube/v3/commentThreads?videoId=pvyfddIFsVA&searchTerms=Google&order=relevance&part=snippet&key=[YOUR API KEY]
Returned Response:
{
"kind": "youtube#commentThreadListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/6qokcCVLNOLwE7dOHNSTr30kECQ\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 20
},
"items": []
}
From the Documentation:
The order parameter specifies the order in which the API response should list comment threads. Valid values are:
time - Comment threads are ordered by time. This is the default
behavior.
relevance - Comment threads are ordered by relevance.
It seems that order by relevance is not working.
This might be a bug, the best option in this case is report the bug by creating a new entry in Issue Tracker.
This is the Issue Tracker entry created by the OP.
I'm new to basically all forms of programming, so forgive me if there's an obvious answer, but I was just trying to make a random video chooser by randomly adding characters to the Youtube API's search function under list, but when I run the API with either just id or id and snippet on, it shows this:
{
"kind": "youtube#searchListResponse",
"etag": "\"i don't know if I can post my etag"",
"regionCode": "CA",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 50
},
"items": [
]
}
.
Its hard to know exactly what you have searched on but by the looks of the result there is just no results for your request. YOu might want to try playing with the api here search.list
When you run it click Execute without OAuth not the authorize and execute button. It will return a random list of videos.
You can use the q parameter to do a text search on videos for example that like toys.
I'm using the playlistItems endpoint to get a list of videos that have been uploaded by an account. The response shows 1 as totalResults, which is expected, but the items array is empty, which is not. It's not clear to me what's going on, since the video is public and has views on it.
I'm not seeing this issue pulling uploads from other accounts, so I'm wondering if it's a caching issue on the YT side, or some setting we need to enable on our account? I'm not able to find any documentation that would explain what's happening here.
The endpoint I'm hitting is https://www.googleapis.com/youtube/v3/playlistItems?key=<api key>&playlistId=UUjQYaIbYceXNNdC63dQ9aTg&maxResults=10&part=snippet, and the full response I'm receiving is:
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/eJKYM5x3WquVgzqxNc7NMRuOS4o\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 10
},
"items": []
}
The item is now showing up, so it looks to just take some time before the API reflects what's been uploaded.