I am using youtube api v3 for get channel's show list. For that i am using following method as it in document,
https://www.googleapis.com/youtube/v3/search?channelType=show&part=snippet&channelId=UC55IWqFLDH1Xp7iu1_xknRA&key={YOUR_API_KEY}
Its give error like 400 Bad Request. Can any one tell me what's wrong wih this api?
Thanks,
Ankur
You need to set type=channel as it says in
"debugInfo": "code: ERROR_INVALID_FILTER\nlocation: \nhttp status:
400\n[debug] Filters on channels are only available when
type=channel\n\ncom.google.api.server.core.Fault:
ImmutableErrorDefinition{base=BAD_REQUEST, category=USER_ERROR,
cause=null, debugInfo=code: ERROR_INVALID_FILTER\nlocation: \nhttp
status: 400\n[debug] Filters on channels are only available when
type=channel\n, domain=youtube.search, extendedHelp=null,
httpHeaders={}, httpStatus=badRequest,
internalReason=Reason{arguments={}, cause=null,
Related
I am trying to access the snippet.actualStartTime value of a youtube livebroadcast, using the v3 API.
I have obtained an oauth2 token, and I am able to retrieve this data just fine, but only for my own channel.
I can't see anything on the documentation (https://developers.google.com/youtube/v3/live/docs/liveBroadcasts)
that indicates this information is private/restricted, it even has a specific flag for "mine", indicating that it is indeed possible to fetch it for other channels, but no matter what i try, i can't seem to gain access to it when providing a videoId from another channel.
Even if i try to query for only the "status" of the livebroadcast it returns an empty items[] array.
This is the request I'm using:
Axios.get(`https://youtube.googleapis.com/youtube/v3/liveBroadcasts?id=${videoId}&part=status`,
{
headers: {
Authorization: `Bearer ${token}`,
Accept: 'application/json'
}
})
YouTube Data API v3 Videos: list endpoint with part=liveStreamingDetails returns item/snippet/liveStreamingDetails/actualStartTime correctly for any YouTube channel.
We got to build our own reporting database for our Youtube channel to measure the channel and video performance.
To support this, we implemented an ETL job to extract using Youtube Analytics API and used below python code to get the data.
def GetAnalyticsData(extractDate,accessToken, channelId):
channelId = 'channel%3D%3D{0}'.format(channelId)
headers = {'Authorization': 'Bearer {}'.format(accessToken),
'accept': 'application/json'}
url = 'https://youtubeanalytics.googleapis.com/v2/reports?dimensions={dimensions}&endDate={enddate}&ids={ids}&maxResults={maxresults}&metrics={metrics}&startDate={startdate}&alt={alt}&sort={sort}'.format(
dimensions='video',
ids=channelId,
enddate= extractDate,
startdate=extractDate,
metrics = 'views%2Ccomments%2Clikes%2Cdislikes%2Cshares%2CestimatedMinutesWatched%2CsubscribersGained%2CsubscribersLost%2CannotationClicks%2CannotationClickThroughRate%2CaverageViewDuration%2CaverageViewPercentage%2CannotationCloseRate%2CannotationImpressions%2CannotationClickableImpressions%2CannotationClosableImpressions%2CannotationCloses',
maxresults = 200,
alt ='json',
sort='-views'
)
return requests.get(url,headers=headers)
We hit this API everyday and get all the video metric and sorted by views in descending order.
This solved our need partially and it returns only 200 videos, if we specify maxResults more than 200, its return 400 error code.
The challenge is, how to get all videos for the given date and given channel?
Thanks in advance.
Regards,
Guna
I am not keen on YouTube analytics API, but it seems that you are looking for startIndex.
startIndex
integer
The 1-based index of the first entity to retrieve. (The default value is 1.) Use this parameter as a pagination mechanism along with the max-results parameter.
I'm taking a youtube url as user input.
The logic I have is as follows:
if(URL === link_to_video) then get video
else if( URL == link_to_channel) then get all_videos_of_channel.
I am doing this via JavaScript and using the YouTube API v3.
The problem is, it seems youtube has two types of URLs to youtube channels.
/channel/, eg:
www.youtube.com/channel/UCaHNFIob5Ixv74f5on3lvIw
/user/,
eg: www.youtube.com/user/CalvinHarrisVEVO
both the above links will take you to the same channel, but my current uploader code supports only /user/CalvinHarrisVEVO.
is there any way to make both the URLs behave similarly in terms of obtaining the channel videos?
One solution would be to parse the url and then apply this logic:
if there is `channel` in the url link
call the APIv3 with the **id** of the channel
Ressource : youtube.channels.list
else if there is 'user'
call the APIv3 with the **forUsername** of the channel
Ressource : youtube.channels.list
Check : https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list
Using the YouTube API, how can I fetch structured data about a video? For instance, given a video that is a movie trailer, how can I find the movie title or topic in a structured format, and other interesting metadata such as the celebrities featured or the director?
Yes. The v3 API allows you do do this via videos/list. Here's an example API call using a trailer for The Dark Knight Rises:
GET https://www.googleapis.com/youtube/v3/videos?part=topicDetails&id=g8evyE9TuYk&fields=items%2FtopicDetails%2FtopicIds&key={YOUR_API_KEY}
(To get a developer key, follow the instructions in our video tutorial).
That sets:
topic: topicDetails
id: g8evyE9TuYk
fields: items/topicDetails/topicIds
In the response body, you get:
{
"items": [
{
"topicDetails": {
"topicIds": [
"/m/0bpm4yw",
"/m/01d5g",
"/m/0btpm6",
"/m/0184dt",
"/m/02vxn"
]
}
}
]
}
These correspond to Freebase mids, which you can lookup using the Freebase API. For instance, the first response corresponds to the Freebase entity The Dark Knight Rises (movie). Once you look up the entity, you can look up related entities such as the director, actors, or genre.
Play around with the API explorer a bit. When you're ready to translate this into code, watch out video about turning the API reference into code.
I found that I got the metadata details I wanted via this request url:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id={YouTubeVideoID}&key={YourAPIkey}
Here is documentation with description of all the returned data fields.
Here's info on how to get an API key.
I am trying to do a YouTube topic search using the YouTube Data API v3. I've found that there are many seemingly popular Freebase topics for which YouTube returns no results even though the safeSearch parameter is set to "none". For instance, when I try to search YouTube for the topic "alcoholic beverage" (/m/012mj) the API throws an exception.
from apiclient.discovery import build
from apiclient.errors import HttpError
DEVELOPER_KEY = "blah blah"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
developerKey=DEVELOPER_KEY)
topic_id = "/m/012mj"
try:
search_response = youtube.search().list(
topicId=topic_id,
type="video",
part="id",
safeSearch="none",
q="",
).execute()
except HttpError,e:
print e
<HttpError 400 when requesting https://www.googleapis.com/youtube/v3/search?topicId=%2Fm%2F012mj&q=&safeSearch=none&part=id&key=AIzaSyC7MDamoleicn233r8mTyK2sohcV4A3Aq8&alt=&type=video returned "Invalid combination of search filters and/or restrictions.">
Any suggestions?
UPDATE
This no longer returns a 400 error. The API now returns a search response with no items. At least this helps me differentiate between an error and a search response with no results. However, it still seems strange that YouTube won't return search results for this topic even with safeSearch set to "none".
Have you considered setting the max-results parameter? I have no experience with the YouTube flavor of the Freebase api, but have read that they recommend limiting the results for videos to 10 rather than accepting the default of 25. Otherwise it is odd that they would send a 400 (bad request) rather than a 401 or so.