Searching Channel with Youtube API - ios

I am using Youtube Data Api V3 in my iOS App. Can some body give me some example for search thing the some Channel by name.
I am trying in the following way but its not working
https://www.googleapis.com/youtube/v3/search/list?key={YOUR_API_KEY}&part=snippet&type=channel&q=AnimalPlanetTV
Can anybody help me how i can get the channel data by name
Thanks

For Searching AnyYoutube Channel
https://youtube.googleapis.com/youtube/v3/channels?part=snippet&q=yoursearchquery&key=yourkey

This is a live example
You need to use Channel list of API V3
The result is like that with snippet
{
"kind": "youtube#channelListResponse",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/RKAMAh1QnoE3ilYYcvWIqvcDEZo\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/MenmiFqQVVN5JQ9MJpC9gddZ4Lw\"",
"id": "UCkEBDbzLyH-LbB2FgMoSMaQ",
"snippet": {
"title": "Animal Planet",
"description": "Animal Planet is the world's only entertainment brand that immerses viewers in the full range of life in the animal kingdom with rich, deep content via multiple platforms and offers animal lovers and pet owners access to a centralized online, television and mobile community for immersive, engaging, high-quality entertainment, information and enrichment.",
"publishedAt": "2007-02-14T18:26:59.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s88-c-k-no/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s240-c-k-no/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-FEsYkupUb-A/AAAAAAAAAAI/AAAAAAAAAAA/6SiqnVvRZJY/s240-c-k-no/photo.jpg"
}
}
}
}
]
}

Related

Retrieve Channels-Tab from YouTube Channel via YouTube-API

As you may know some Content-Creators on YouTube not only got one Channel. Some Channels have a Channel-Tab where you can see the other channels hosted by the creator. I would like to get these channels, but unfortunately the YouTube-API can't retrieve the data via channels: list. Is there a parameter or another function how I can get this information?
Channel example: https://www.youtube.com/c/DunklerParabelritter/channels
Thank you in advance,
Aaron!
It seems that once again YouTube Data API v3 doesn't provide a basic feature.
I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/channels?part=channels&id=CHANNEL_ID the data you are looking for are in item["channelSections"].
Note that the channel id associated to the channel you shared is UCK4LDHLxBqiAtcwCm4z7DRg, so you would obtain:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UCK4LDHLxBqiAtcwCm4z7DRg",
"channelSections": [
{
"title": "Mit Empfehlung des Dunklen!",
"sectionChannels": [
{
"channelId": "UCWZu-P34DVZUVrYAROU3Cmw",
"title": "Prinz",
"thumbnails": [
{
"url": "https:\/\/yt3.googleusercontent.com\/knQfgyidSRlVLQfAw64R9DFWmnQt3BwdJUaRW1zHEVRgLswRcR9lsan_S4tGe4BfYJyo9Jppbg=s48-c-k-c0x00ffffff-no-rj-mo",
"width": 48,
"height": 48
},
...
],
"videoCount": 128,
"subscriberCount": 111000
},
...
],
"nextPageToken": null
}
]
}
]
}

Is possible somehow explore youtube videos by hashtag?

I have been looking at the YouTube API and I am wondering if it is possible somehow search YouTube videos by hashtags e.g.
I want explore YouTube video for hashtag #funny
I have read YouTube API documentation but I haven't found anything.
Search: list
Returns a collection of search results that match the query parameters specified in the API request. By default, a search result set identifies matching video, channel, and playlist resources, but you can also configure queries to only retrieve a specific type of resource.
In my experience this is a full text search on title and description of the video so assuming your hash tags are in the description you should be able to search on them.
Request
GET https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&q=%23funny&key={YOUR_API_KEY}
Response
{
"kind": "youtube#searchListResponse",
"etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/wR5yPzOxAnu-87xJGtSkLXz_78Q\"",
"nextPageToken": "CBkQAA",
"regionCode": "DK",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 25
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/IByts9zZTVNkc5EfbIDTKpE6pf8\"",
"id": {
"kind": "youtube#video",
"videoId": "DODLEX4zzLQ"
},
"snippet": {
"publishedAt": "2017-06-17T10:03:47.000Z",
"channelId": "UCKy3MG7_If9KlVuvw3rPMfw",
"title": "WATCH and TRY TO STOP LAUGHING - Super FUNNY VIDEOS compilation",
"description": "Can you hold your laugh while watching these clips? :) Mix of best and funniest animal & human fails. We bet you will lose this laugh challenge. Anyways, what is your favorite clip? :) Hope...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/DODLEX4zzLQ/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/DODLEX4zzLQ/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/DODLEX4zzLQ/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Tiger Productions",
"liveBroadcastContent": "none"
}
},
This is the video it returned WATCH and TRY TO STOP LAUGHING - Super FUNNY VIDEOS compilation #funny is in the description.
You can try it yourself here Google Apis Explorer

Localization data missing from Youtube data API

I am currently using the Youtube data API trying to get localised subtitle data and while this works for most videos it isn't working for this one: https://www.youtube.com/watch?v=Q0FhXknxYj4. The video has Danish subtitles but when you use the API or API demo (setting part as localization) here: https://developers.google.com/youtube/v3/docs/videos/list there is no subtitle data.
Example response for working video:
{
"kind": "youtube#videoListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/zgsYC3imu6Fd_dFVfGFSGv4yads\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/3xUeT9GTC6osUJsmbTXqY1OMfsc\"",
"id": "S3YnYrcD1sQ",
"localizations": {
"da": {
"title": "København: Europas første markedsplads for byrelaterede data - Hitachi",
"description": "Hitachi skaber en datamarkedsplads for Danmarks hovedstad, der skal styrke innovationen.\n\nhttp://www.hitachi.eu/en/case_studies/city-data-exchange"
},
"en": {
"title": "Copenhagen: Europe's first city data exchange - Hitachi",
"description": "Hitachi is creating a data marketplace for Denmark's capital, to help power innovation.\n\nhttp://www.hitachi.eu/en/case_studies/city-data-exchange"
}
}
}
]
}
Example response for broken video (Q0FhXknxYj4):
{
"kind": "youtube#videoListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/UrnoPP0xkF1sGZFODge_h_h01KU\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/Y82zqHiktkqS1qFvTSCoJ5BEJas\"",
"id": "Q0FhXknxYj4"
}
]
}
Does anyone know why the API might not pull in the localisation data even though the subtitles are there?
Many thanks,
Emily
Your first example does not contain any subtitle data either. It only contains localizations of the video title and description.
You need to be using captions, not list, to list subtitle details.

Certain videos not showing up in the api results

I have noticed that all videos from the account, Kanye West - Topic, don't show up in the api results. Does anyone have a reason why or a solution to fix this? For example, when I use the api search GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCRY5dYsbIN5TylSbd7gVnZg&type=video&key={YOUR_API_KEY}, it says there are 961 total results but the items section is empty.
Your GET request is correct but it's missing additional field resources parameters, so it doesn't know what you want to retrieve. I've added the fields to your GET REQUEST using the Google API Explorer and here's what it looks like:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCRY5dYsbIN5TylSbd7gVnZg&maxResults=50&q=%22Kanye+West%22&fields=etag%2CeventId%2Citems%2Ckind%2CnextPageToken%2CpageInfo%2CprevPageToken%2CregionCode%2CtokenPagination%2CvisitorId&key={API_KEY_HERE}
And the response was:
{
"kind": "youtube#searchListResponse",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/6VdmXA4FhXjg08y58iRnmXZY7wQ\"",
"nextPageToken": "CDIQAA",
"regionCode": "PH",
"pageInfo": {
"totalResults": 841,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/VSzDMW_CqJw-OMjo_vzPR2P40eI\"",
"id": {
"kind": "youtube#channel",
"channelId": "UCRY5dYsbIN5TylSbd7gVnZg"
},
"snippet": {
"publishedAt": "2013-07-02T20:09:18.000Z",
"channelId": "UCRY5dYsbIN5TylSbd7gVnZg",
"title": "Kanye West - Topic",
"description": "Kanye Omari West is an American rapper, songwriter, record producer, fashion designer, and entrepreneur. Born in Atlanta and raised in Chicago, West first ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/1.jpg"
},
"medium": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/mq1.jpg"
},
"high": {
"url": "https://i.ytimg.com/i/RY5dYsbIN5TylSbd7gVnZg/hq1.jpg"
}
},
"channelTitle": "Kanye West - Topic",
"liveBroadcastContent": "none"
}
.. (long list below)
If you want to conduct additonal test, use the Youtube API Explorer.

Youtube Data API v3 search query with Freebase topics id and date

I am trying to use the YouTube Data API to search video by using Freebase topics.
It works for a simple search with one topic but it doesn't work for a search with 2 parameters : a topic id and a "publishedAfter" date.
For example, to search for videos about Richard Branson (Freebase id = /m/0n839), the youtube data api site :
https://developers.google.com/youtube/v3/docs/search/list#try-it
with the parameters :
part : snippet
topicId : /m/0n839
show a result of 2165 videos
But when you try to search videos about id = /m/0n839 with
part : snippet
topicId : /m/0n839
publishedAfter : 2013-05-21T21:47:38Z
the response indicates 147 videos but only 3 videos are contained in the response.
In the response, you can see that the 3 video ids are J6PY5vxLU8Y, SCkFwpW3kiE, CBvDp0i8Iok.
{
"kind": "youtube#searchListResponse",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/_-rYO0M0nvpPO6QN7DPFGEYa9ho\"",
"pageInfo": {
"totalResults": 147,
"resultsPerPage": 5
},
"nextPageToken": "CAUQAA",
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/3nxQ-ejnv0qekcbyq09HD2RQt_w\"",
"id": {
"kind": "youtube#video",
"videoId": "J6PY5vxLU8Y"
},
"snippet": {
"publishedAt": "2013-05-22T09:58:34.000Z",
"channelId": "UCimPiDCqxvfqwVJltL4YzHg",
"title": "Bono, Richard Branson, and Olivia Wilde Joined Matt Damon's Strike!",
"description": "Support the strike: http://strikewithme.org/ Millions of celebrities have joined Matt Damon's \"Toilet Strike\" protesting the lack of access to safe water and...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/hqdefault.jpg"
}
},
"channelTitle": "water"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/gNslTbFkShGLlUBcXgHw7q9tuJc\"",
"id": {
"kind": "youtube#video",
"videoId": "SCkFwpW3kiE"
},
"snippet": {
"publishedAt": "2013-05-23T16:27:31.000Z",
"channelId": "UCeF4WiRKOA4XzphWYzR9aVw",
"title": "Sir Richard Branson dresses as an air stewardess after losing bet",
"description": "(Reuters) - A man was arrested at the Cannes film festival on Friday after firing a starting pistol during a live TV broadcast on the palm-lined waterfront, ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/SCkFwpW3kiE/hqdefault.jpg"
}
},
"channelTitle": "TheDailyPolitics247"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/-_OEOHhzgCBTLr7x5UoDk2kHlJM\"",
"id": {
"kind": "youtube#video",
"videoId": "CBvDp0i8Iok"
},
"snippet": {
"publishedAt": "2013-05-25T22:38:00.000Z",
"channelId": "UC2j75rAKcfjBAhW7WmNY4Qg",
"title": "Virgin Galactic Spaceship Passes Big Test (Y)",
"description": "A spaceship bankrolled by British tycoon Sir Richard Branson made its first engine-powered flight Monday. The test flight moves Virgin Galactic toward its go...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/CBvDp0i8Iok/hqdefault.jpg"
}
},
"channelTitle": "NewActionNews"
}
}
]
}
If you search for the next videos with nextPageToken : "CAUQAA", the response contains the same video ids (J6PY5vxLU8Y, SCkFwpW3kiE, CBvDp0i8Iok):
{
"kind": "youtube#searchListResponse",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/xMtmG2pQsuo_TFF8AtaaPea-cNc\"",
"pageInfo": {
"totalResults": 144,
"resultsPerPage": 5
},
"nextPageToken": "CAoQAA",
"prevPageToken": "CAUQAQ",
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/3nxQ-ejnv0qekcbyq09HD2RQt_w\"",
"id": {
"kind": "youtube#video",
"videoId": "J6PY5vxLU8Y"
},
"snippet": {
"publishedAt": "2013-05-22T09:58:34.000Z",
"channelId": "UCimPiDCqxvfqwVJltL4YzHg",
"title": "Bono, Richard Branson, and Olivia Wilde Joined Matt Damon's Strike!",
"description": "Support the strike: http://strikewithme.org/ Millions of celebrities have joined Matt Damon's \"Toilet Strike\" protesting the lack of access to safe water and...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/J6PY5vxLU8Y/hqdefault.jpg"
}
},
"channelTitle": "water"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/cEIRgKqwt1aa9hcWMNtGTiCJImc\"",
"id": {
"kind": "youtube#video",
"videoId": "h7hJ3FDGWY8"
},
"snippet": {
"publishedAt": "2013-05-22T10:01:25.000Z",
"channelId": "UCqcE1T9zcUQyX3hHH4EM7sQ",
"title": "Sir Richard Branson in Dubai",
"description": "The man behind the Virgin brand stopped by Kris Fade's show last week - broadcasting from the Burj Khalifa, the world's tallest building.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/h7hJ3FDGWY8/hqdefault.jpg"
}
},
"channelTitle": "Kimberleyleonard"
}
}
]
}
Did I do something wrong ?
The "totalResults" attribute has, in previous versions of the API, always just been an estimated value that the search algorithms provide before actually retrieving any results, so it's likely safe to assume that is the case for v3 as well. However, it is a little odd that the estimate could be so far off; for your query, there really are just several results (5 or 6, I think ... as several have been uploaded since you made this initial post).
I've played around with various parameters for a bit, and it looks as though the factor which has the single-most influence as to the accuracy of the totalResults approximation is the 'q' parameter -- the more specific of a value you provide there, the more accurate the totalResults become.
Of course, in your query, then, the q parameter is empty, and the totalResults approximation is incredibly far off (in fact, if you change the publishedAfter parameter to be May 1st intead of May 21st, you actually get it approximating LESS total results, even though it's an earlier date!). If you do a query like this, however:
https://www.googleapis.com/youtube/v3/search?part=id&maxResults=50&publishedAfter=2010-05-01T21%3A47%3A38Z&topicId=%2Fm%2F0n839&key={YOUR_KEY}&q=Bran
Then you get a totalResults approximation that exactly matches the number of real results.
Of course this can be frustrating, because when incorporating Freebase IDs you often don't WANT to use the q parameter -- the whole point of freebase IDs is to use semantically relevant info that's based in more than just string matching! But it's clear that this is telling us something about the internal YouTube search algorithms and what they rely on. I'd venture that as Freebase integration becomes more mature, the search algorithms will be better able to adapt and you'll start seeing better totalResults approximations again.
As a workaround, you can use what you've noticed with the 'nextPageToken' to get a better count. In your query, set your maxResults to 50, and when you get actual results, have your routine count them. If they're less than 50, you've got them all. If it is 50 on that page, you might want to pre-fetch the next set of results (if they are new results, you're good to go, while if they are the same results as what you have, then you had exactly 50 responses). The one problem is that this will prevent you from displaying in your app an accurate count of total results (i.e. if you've got pagination going somewhere), so it's not perfect, but what workaround is?
I'm pretty sure the discrepancy between number of results and number actually shown is due to how date restrict ( start_time: 1369172858, the representation of "publishedAfter : 2013-05-21T21:47:38Z") is implemented.
By the way, I now see 10 matches, including the three mentioned.
First results are retrieved using the narrowist restrict range that includes the requested date range. That's how you can get ~140 matches. The videos that survive retrieval are then filtered, rejecting those outside the actual requested range. It's pretty plausible that 130 videos are dropped at that stage, leaving the 10 that actually satisfy the request.
The count of matches indicates number retrieved -- for date range, this will typically be an overestimate, possibly severe.
We generally don't warrant that the number reported as "matched" all actually match, since various kinds of filtering happen after retrieval.

Resources