YouTube API v3 returns no items - youtube-data-api

A week ago I started using the YouTube API v3, and have been able to retrieve 13 items from the API using this URL:
https://www.googleapis.com/youtube/v3/search?key={MyKey}&channelId={AChannelId}&part=snippet,id&order=date&maxResults=5
Today I used this exact same call/URL and now it returns:
// 20140828161458
// https://www.googleapis.com/youtube/v3/search?key={MyKey}&channelId={AChannelId}&>part=snippet,id&order=date&maxResults=5
{
"kind": "youtube#searchListResponse",
"etag": "\"gLjvtM18QUCicnbwPLo7vn_YIlg/Z7muB3yLsIIdSeQTKlRVObzSk8M\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
So no items are being returned, eventhough there should be 13. I used another channelId to make sure the problem wasn't in the channelId, but it also returned nothing.
I have checked the Google blog, but there was no mention of a change. Anyone have an idea what could be wrong?

Related

How i can get list of popular youtube channels per each country?

How i can get list of popular youtube channels per each country?
this service find solution
https://www.channelcrawler.com/eng/results2/281574
I tried youtube api but i didn't find, anyone know solution?
As mentioned, is not possible to get this information using the YouTube API directly, even in the FAQ of the page you shared says:
The Channel Crawler was made to discover new YouTube channels, based on your search criteria.
and:
The Channel Crawler uses advanced data collection methods in order to collect channel information from YouTube and store it in the database. Basically, it just checks the liked videos and comment sections of channels that are already in the database, in order to add more channels to it. You can also manually add a channel.
Following the highlighted information, I have this idea and you can try it too:
Use the search endpoint for search channels in a specific country and in a specific videoCategory, then, with the channelId returned in the results of the search, use the channel endpoint for get their country1.
1 take into account that some channels doesn't have the country value; in this case, you have to set another criteria(s) for determine whether the channel matches with your requirements.
Example:
Use the search endpoint for search channels in country/region Pakistan and in the videoCategory Sports - test it here:
URL:
https://youtube.googleapis.com/youtube/v3/search?part=id%2Csnippet&order=videoCount&q=Sports&regionCode=PK&key=[YOUR_API_KEY]
The results of this request are as follows:
{
"kind": "youtube#searchListResponse",
"etag": "0C7hSI3oNXJt66PsERuviVQcLCo",
"nextPageToken": "CAUQAA", // Remember the nextPageToken for get the next results.
"regionCode": "PK", // Region queried.
"pageInfo": {
"totalResults": 1000000, // Look the amount of data you have to check, filter and debug.
"resultsPerPage": 5 // Set "maxResults" parameter to "50" for get more results per page.
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "iSwEnBs_yV6lOIBubmRXVwjjujQ",
"id": {
"kind": "youtube#channel", // Make sure that this item is actually an channel.
"channelId": "UCo2TvjBHS1BtyIkeGGTMe6w"
},
"snippet": {
"publishedAt": "2018-07-28T18:34:04Z",
"channelId": "UCo2TvjBHS1BtyIkeGGTMe6w", // Use this value for the "channel" endpoint.
"title": "ONTime Sports",
"description": "قناة اون تايم سبورت واحدة من مجم...",
"thumbnails": { [thumbnails here...] },
"channelTitle": "ONTime Sports",
"liveBroadcastContent": "upcoming",
"publishTime": "2018-07-28T18:34:04Z"
}
},
[other results here...]
]
}
Use channel endpoint for get the channel detailed information - in this case, their country - test it here:
URL - using the channelId UCo2TvjBHS1BtyIkeGGTMe6w - obtained from the previous search results:
https://youtube.googleapis.com/youtube/v3/channels?part=id%2Csnippet&id=UCo2TvjBHS1BtyIkeGGTMe6w&key=[YOUR_API_KEY]
The results of this request are as follows:
{
"kind": "youtube#channelListResponse",
"etag": "8BfUXxlAEBLe7lBmih1JXUwZ394",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "AFk5NCl9393ui58WyRf7WljoatE",
"id": "UCo2TvjBHS1BtyIkeGGTMe6w",
"snippet": {
"title": "ONTime Sports",
"description": "large description here...",
"customUrl": "ontimesportseg",
"publishedAt": "2018-07-28T18:34:04Z",
"thumbnails": {[thumbnails here]},
"localized": {
"title": "ONTime Sports",
"description": "large description here..."
},
"country": "EG" // This is the regionCode of the country this channels has provided.
}
}
]
}
Here, you can see that the value "country" for this channel is "EG" = Egypt2.
Then, repeat these steps with all countries and videoCategory for each country.
Considerations:
As I tested, the type parameter in search is not working as one might expect, in this case (for get channels only), use the order=viewCount combination of parameter=value. Even with this combination, make sure to check that the value of the kind attribute is: youtube#channel. Also, I search the videoCategory using its name, no its id - as it should be -, but, the API is not perfect, that's why I used the name of the videoCategory.
Even specifiyng the region parameter with a valid country, you might get results that are either from another countries or doesn't have the country attribute and value at all = and that's due the channel's popularity in the given country and public channel information. A simple example could be: ESPN, they probably have a YouTube channel for each country, but, their main channel is the most popular in all countries, so, in this case, you'll get the ESPN channel in english and that might differ from your expected results. You have to work with what YouTube provides.
As you notice, there are too many channels/results to debug, so, make sure to provide more filters and set your queries/search criteria and (once you get the desired results), store the valid results in a database or similar.
If you know specific channels that you know are popular in a given country, but, when you query that channel using the YouTube Data API, it doesn't bring the country value, you have to save that channel manually in your database and/or collect more information for automatically set if a channel is from a given country - this point is very related to my point # 2.

How to get all uploads from official artist channels via the youtube data api

I am trying to query youtube for all uploads relating to a channel, but for official artist channels such as: https://www.youtube.com/channel/UC-jHioVmLr8Cb1lFBIZD2hQ/
When I try to make the API call to retrieve the "uploads" playlist, it succeeds, but returns an empty playlist.
Finding the uploads playlist via https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UC-jHioVmLr8Cb1lFBIZD2hQ (API key omitted) returns
{
"kind": "youtube#channelListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/SQbT6DxUQ-PRgTma_VN0xA8OmHE\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/m44G0g4BqX0Af7CaFKoFcqJDqm0\"",
"id": "UC-jHioVmLr8Cb1lFBIZD2hQ",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UU-jHioVmLr8Cb1lFBIZD2hQ",
"watchHistory": "HL",
"watchLater": "WL"
}
}
}
]
}
but retrieving the items in the uploads playlist via https://www.googleapis.com/youtube/v3/playlistItems?playlistId=UU-jHioVmLr8Cb1lFBIZD2hQ&part=id,contentDetails&maxResults=50 returns
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/E0c9LqWjuNHvL-UjCIKS4N9Fn5M\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 50
},
"items": []
}
I would like to be able to just pull the videos that show up from the videos tab, but cannot seem to do that with the api.
The reason why you don't have results is because that YouTube channel (i.e. HRVY) hasn't uploaded videos (yet).
You can check the uploaded videos page from HRVY channel.
There, you can see that no videos are uploaded, but you might wonder: how this is possible if I can see videos on this channel?
Unfortunately, I can't say for sure why this happened, but, if you still wants to retrieve the videos from that channel, retrieve videos from a specific playlist by using the playlistId and not the uploads id.
For example, the "Most Popular" playlist from that channel has its playlistId: PLtz80rG4U0K99mMxPLNFPhwBIKkvzx9x1.

How to make publishedAfter field working?

I'm trying to get videos of a particular channel using search/list API method. But looks like publishedAfter field doesn't work.
Example: https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCgxTPTFbIbCWfTR9I2-5SeQ&maxResults=50&order=date&publishedAfter=2019-01-01T00:00:00Z&type=video&key=MYKEY
"totalResults": 1546,
...
{
"kind": "youtube#searchResult",
"etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/ZrInvdAerhIEEIuhaU-Op01jNGQ\"",
"id": {
"kind": "youtube#video",
"videoId": "lkHUuL_qBKc"
},
"snippet": {
"publishedAt": "2018-10-05T16:45:52.000Z",
"channelId": "UCgxTPTFbIbCWfTR9I2-5SeQ",
"title": "🔥 Путин обманул. Квартира за 2 млрд. ГРУ",
...
There are less than 150 videos with publishedAt > 1st of January, but API returns 1546 videos and the results contain videos, that were published before 1st of January, the above example shows 5th of October, 2018. Looks like API ignores publishedAfter condition as well as order=date.
It's weird, but two days ago the same url with the same key gave correct results.
Is it possible to get correct search results?
It's not your fault. Right now, it's seems like a global problem.
Read here - https://support.google.com/youtube/thread/2494861?hl=en
My youtube app is broken too.

Youtube API empty channels list by categoryId

On Youtube API manual for Channels method channels.list
categoryId parameter is described as "YouTube guide category".
I've got guide categories list by
https://www.googleapis.com/youtube/v3/guideCategories?part=snippet&regionCode=RU&key=cannot_publish_my_api_key_here
But when I'm trying to get channels list by id of every guide category from that list, for example,
https://www.googleapis.com/youtube/v3/channels?categoryId=GCTmV3cyAmIFBvbGl0aWNz&key=&part=snippet
I'm always getting an empty result
{
"kind": "youtube#channelListResponse",
"etag": "m2yskBQFythfE4irbTIeOgYYfBU/ewwRz0VbTYpp2EGbOkvZ5M_1mbo",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
What I do wrong?

Youtube Data Api v3 search list return nothing

recently, the search list api (event type: live) return nothing
example: https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&eventType=live&type=video&key={YOUR_API_KEY}
return
{
"kind": "youtube#searchListResponse",
"etag": "\"5g01s4-wS2b4VpScndqCYc5Y-8k/jg2CTBtu0DNa8PVkxeurAMgwBzc\"",
"regionCode": "TW",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
does anyone has this problem too?
this api used to can get live channel, but it return nothing now
I got the result dude at
https://developers.google.com/youtube/v3/docs/search/list#try-it.
Some times it does not work means, developer is improving api, or may be server problem. Its not a big thing.

Resources