Youtube API empty channels list by categoryId - google-api

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?

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.

Filter video list by tag

Goal
Get videos, ordered by date, and filtered by tag from a specific YouTube channel. I need only the videos that have that unique tag. I understand I can get the latest uploaded videos, then one by one query YouTube API for each video and determine if it has the tags I need. But I find that too lengthy and wonder if there's a single API request than can handle that filter for me.
Tried
Reading this API documentation I understood the snippet was supposed to have a snippet.tags:
snippet.tags[]
list
A list of keyword tags associated with the video. Tags may contain spaces. The property value has a maximum length of 500 characters. Note the following rules regarding the way the character limit is calculated:
The property value is a list, and commas between items in the list count toward the limit.
If a tag contains a space, the API server handles the tag value as though it were wrapped in quotation marks, and the quotation marks count toward the character limit. So, for the purposes of character limits, the tag Foo-Baz contains seven characters, but the tag Foo Baz contains nine characters.
Using the following (search/list)
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=CHANNEL_ID&maxResults=10&order=date&type=video&key=MY_GOOGLE_CONSOLE_KEY
I get:
{
"kind": "youtube#searchResult",
"etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/MO86DiShKKJ483oXkFJdDmvBd5M\"",
"id": {
"kind": "youtube#video",
"videoId": "jMywJTXhkVs"
},
"snippet": {
"publishedAt": "2017-09-16T15:28:40.000Z",
"channelId": "UC4GRKWUEhUvsCqD-yNQpxQw",
"title": "Real Time - Gesture Drawing 7 (5.10 mins time)",
"description": "Join me in gesture drawing practice from photo reference. :) References (in order of drawing) - Thank you to SenshiStock (https://senshistock.deviantart.com/) ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/jMywJTXhkVs/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/jMywJTXhkVs/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/jMywJTXhkVs/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Chayemor",
"liveBroadcastContent": "none"
}
}
The snippet only includes publishedAt, channelId, title, and description, certainly no tags.
Looking into /search/list documentation I see that it has another parameter that I might be able to use:
q
string
The q parameter specifies the query term to search for.
Your request can also use the Boolean NOT (-) and OR (|) operators to
exclude videos or to find videos that are associated with one of
several search terms. For example, to search for videos matching
either "boating" or "sailing", set the q parameter value to
boating|sailing. Similarly, to search for videos matching either
"boating" or "sailing" but not "fishing", set the q parameter value to
boating|sailing -fishing. Note that the pipe character must be
URL-escaped when it is sent in your API request. The URL-escaped value
for the pipe character is %7C.
So I use the tag "sketching" that I know is set in various videos. (A way to determine if a single video's tags is through https://www.googleapis.com/youtube/v3/videos?key=GOOGLE_KEY&fields=items(snippet(title,description,tags))&part=snippet&id=video_id )
https://www.googleapis.com/youtube/v3/search?q=%22sketching%22&part=snippet&channelId=CHANNEL_ID&maxResults=25&order=date&type=video&key=GOOGLE_KEY
That yields this:
{
"kind": "youtube#searchListResponse",
"etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/hPC7YXbOHVWNEk_6UiC5Jzdh5Zs\"",
"regionCode": "ES",
"pageInfo": {
"totalResults": 10,
"resultsPerPage": 25
},
"items": []
}
Nothing else. It says there are 10 results, but I don't see them, I do't know what they are. I tried sending the request without the "" but it returned the same result. Messing around I saw that when searching within a channel's videos from YouTube (as a browser client, through GUI, not API), it uses the parameter 'query'. So out of not having any more ideas I decided to substitute q for query.
https://www.googleapis.com/youtube/v3/search?query=sketching&part=snippet&channelId=UC4GRKWUEhUvsCqD-yNQpxQw&maxResults=25&order=date&type=video&key=GOOGLE_KEY
That query did yield results, but not of those videos who had that unique tag, but rather any video that had that tag or that word used in the title or description.
{
"kind": "youtube#searchListResponse",
"etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/xjWZRnm0X7B_csQX4KEu9nv_qdQ\"",
"regionCode": "ES",
"pageInfo": {
"totalResults": 24,
"resultsPerPage": 25
},
"items": [ ... ]
}
Any suggestions?

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.

YouTube API v3 returns no items

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?

Resources