Is there any way to have updated lists of top 100 videos of youtube by genre and/or by country!
Any kind of resources like json files or xml.
You'll want to use the chart parameter of the videos.list endpoint. Set the chart to mostPopular, and then include a regionCode parameter and videoCategoryId parameter for further narrowing down. For example,
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular®ionCode=UA&key={YOUR_API_KEY}
Will retrieve the 5 most popular videos in the Ukraine.
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=25®ionCode=DE&videoCategoryId=1&key={YOUR_API_KEY}
Will retrieve the 25 most popular videos in Germany that relate to Film/Animation. And so on.
Note that if you don't include a videoCategoryId parameter, it will return results from all categories. If you don't include a regionCode, it returns the most popular videos across all regions. You can only set videoCategoryId to a value that's valid in the region you're searching in (you can use the videoCategories.list endpoint to find valid categories for regions, languages, etc.)
Related
In YouTube's Data API, data are returned in fields, and fields are grouped in parts. In the YouTube documentation, YouTube Data API Overview, the section, How to use the part parameter, gives a list of the parts available for videos:
snippet, contentDetails, fileDetails, player, processingDetails, recordingDetails, statistics, status, suggestions, topicDetails
There are two things I have not found in the documentation:
The list of parts available for channels and playlists.
The list of fields available in each part for videos, channels, and playlists.
Where can I get that information?
Also, some fields are available to the public, while others are only available to the owner of the subject resource. So in the list of fields, I need to know which I can query and which are restricted.
Found the answer:
Channels
Parts: docs/channels/list#parameters
Fields: docs/channels#properties
Restrictions: docs/channels/list#auth
Playlists
Parts: docs/playlists/list#parameters
Fields: docs/playlists#properties
Restrictions: If there are any, they don't seem to be documented.
Playlist items
Parts: docs/playlistItems/list#parameters
Fields: docs/playlistItems#properties
Restrictions: If there are any, they don't seem to be documented.
Videos
Parts: docs/videos/list#parameters (The list at that link gives three additional parts that are not in the list at How to use the part parameter: id, liveStreamingDetails, and localizations.)
Fields: docs/videos#properties
Restrictions: Stated in the descriptions of the fileDetails, processingDetails, and suggestions fields.
===================================
Fields that are missing from my previous answer are
contentDetails
regionRestriction
hasCustomThumbnail
status
failureReason
rejectionReason
publishAt (But this should never appear in a public listing because it only applies to videos with privacyStatus = 'private`.)
selfDeclaredMadeForKids (But only returned if authorized.)
statistics
dislikeCount (But only returned if authorized.)
player
embedHeight
embedWidth
recordingDetails
location
recordingDate
liveStreamingDetails
6 fields
localizations
key (language)
I have used a method to get a partial list of the public fields available for videos. This is a hack and I hope someone will post a better answer, preferably a link to the answer in official YouTube documentation.
Until we get that answer, here is the hack I used:
First, I took the list of the ten parts given for videos and submitted it in an API call for three arbitrary videos:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,fileDetails,player,processingDetails,recordingDetails,statistics,status,suggestions,topicDetails&id=XqZsoesa55w,kJQP7kiw5Fk,F4tHL8reNCs&key=<key>
The result was this error message:
The request is not properly authorized to access video file or
processing information. Note that the fileDetails,
processingDetails, and suggestions parts are
only available to that video's owner.
That is information. It tells me that those three parts are not publicly available, so I can't query them on videos I don't own.
So next I submitted the same request with those three parts removed:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,player,recordingDetails,statistics,status,topicDetails&id=XqZsoesa55w,kJQP7kiw5Fk,F4tHL8reNCs&key=<key>
I then took the response from that and parsed the JSON to extract the labels at the third and fourth level of nesting. These are mostly the part and field names. The first three rows of the following table are fields; the rest are parts with their constituent fields.
Field or part
Field
kind
etag
id
snippet
publishedAt
channelId
title
description
thumbnails
channelTitle
tags
categoryId
liveBroadcastContent
defaultLanguage
localized
defaultAudioLanguage
contentDetails
duration
dimension
definition
caption
licensedContent
contentRating
projection
status
uploadStatus
privacyStatus
license
embeddable
publicStatsViewable
madeForKids
statistics
viewCount
likeCount
favoriteCount
commentCount
player
embedHtml
topicDetails
topicCategories
recordingDetails
Notice that part recordingDetails has no fields listed. That doesn't mean it has no fields. It means that none of the videos for the IDs submitted have recordingDetails in their data. That is why I said at the beginning that what I've got is a partial list. It is only based on the data retrieved for those three videos. Another example of this issue is that only two of the three videos submitted have a commentCount in their data. If none of them had data for that field, then I would not know about the existence of that field from this exercise.
So there's my partial list of public fields for videos. Can someone give us a better answer pointing to documentation of all the fields for videos, channels, and playlists?
I need get a list of most viewed music video on Youtube.
I used this API:
https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&chart=mostPopular®ionCode=US&videoCategoryId=10&key=[YOUR_API_KEY]
By default regionCode is US, I want get results by global.
Can someone help me?
You can't really using using the chart means you must include a reagion and the default is the USA.
string
The regionCode parameter instructs the API to select a video chart available in the specified region. This parameter can only be used in conjunction with the chart parameter. The parameter value is an ISO 3166-1 alpha-2 country code.
remove ®ionCode=US Should be the same as US
GET https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&chart=mostPopular&key=[YOUR_API_KEY]
You would have to query EACH region and take the videos with the highest cumulative viewCount over all regions. This would be difficult as different regions will have different music videos that are most popular. Unfortunately the API doesn't have a global regionCode option.
i would like to crawl Youtube for videos of a specific language that contains subtitles/closed-captions(CC).
For example,
I want to crawl for 200 random English videos with English subtitles/(CC).
I want to crawl for 300 random Chinese videos with Chinese subtitles/(CC).
I want to crawl for 550 random Malay videos with Malay subtitles/(CC).
There's an api here that helps to extract transcripts, but the main bottleneck right now is that i have to go youtube to search for these videos and watch one by one to find out if they are indeed in the correct language, and if they really contain subtitles/CC.
An option is:
Use YouTube Data API - search request for search videos that contains subtitles; for that, use videoCaption parameter with value: closedCaption.
You might need use another parameters for reduce the search terms to specific topics or get certain desired results; for example, for the q parameter, use a search term that retrieves the desired results; also all parameters like: videoDuration, type = video, relevanceLanguage.
Once you got such results, copy/paste the videoId you got from the results of the request and use your web-crawler for get more videos and the related ones.
For anyone still struggling with this, and as per the YouTube Data API for videoCaption to work, you need to also set the type parameter's value to video:
If you specify a value for this parameter, you must also set the type
parameter's value to video.
hello friends i am using youtube search api
https://www.googleapis.com/youtube/v3/search?pageToken=CDIQAA&part=snippet&location=40.748817%2C-73.985428&locationRadius=1km&maxResults=50&type=video
but in response i am not getting location attributes . I have only channel Id and video id and i want posted location .
Tested your search query, it returned a 200 OK but with no results and when I changed the query to 10KM radius, I got 23 results. Anyhow, the location details you are searching are a part of recordingDetails as shown here. Scroll down to Resource Representation on that page. This is an optional parameter and does not necessarily have to be included. However, recordingDetails are a part of the Videos List and Search endpoint doesn't allow you to query those. So you might have a better chance querying the Videos List endpoint.
Scroll down to the bottom of Videos List link and enter the following value to see what I mean:
part - snippet,recordingDetails
chart - mostPopular
maxResults - 50
This endpoint accepts Video ID as an input and would allow you to search for a video using it's ID.
As you can also see in the Videos Insert endpoint, these are optional parameters left for the uploader to define. Hence, if you're not getting any results it probably means they were not defined for that video.
I'd like to retrieve the tweets for given a hashtag and sort them from the most retweeted to the less retweeted.
The closest thing I've found is using the search call and use the type tag:
E.g.: http://search.twitter.com/search.json?q=TheHashTagHere&result_type=popular
However, I'm not sure on how "popular" option works.
For instance, if it finds 100 tweets with that hashtag I believe it should show the X most retweeted tweets, and if none of those tweets have been retweeted then it should show X of them randomly (or sorted in some other way like the most recent).
Unfortunately, if follows some kind of unknown rule to identify what's popular and what not and even hashtags with thousands of tweets might return only one or two results.
I hope I made myself clear. Thanks in advance :)
PS: I'll use PHP but I think that shouldn't affect the question?
Results will sometimes contain a
result_type field into the metadata
with a value of either "recent" or
"popular". Popular results are derived
by an algorithm that Twitter computes,
and up to 3 will appear in the default
mixed mode that the Search API
operates under. Popular results
include another node in the metadata
called recent_retweets. This field
indicates how many retweets the Tweet
has had.
Source (Emphasis are mine)
Just call with result_type=popular and check the recent_retweets node to see how popular it is. result_type=popular will become the default in an upcome release so beware if you omit this parameter.
Results with popular tweets aren't ordered chronologically. *
If you would like to always have results to show, use result_type=mixed: they will have the result_type in the "metadata" section with a value of "recent", and popular results will have "popular". A small reference about result_types:
mixed: Include both popular and real time results in the response.
recent: return only the most recent results in the response
popular: return only the most popular results in the response.
If a search query has any popular results, those will be returned at the top, even if they are older than the other results. *
*[Twitter API Announcements]
This isn't a programmatic method but rather works in the browser with a chrome extension (HackyBird) :
Install the extension
Search for a phrase e.g. #Social (twitter.com/search?q=%23Social)
Click the extension to sort it (you can adjust the ratio of retweets/likes used for sorting in extension options).
P.S. It'll also sort your or any other user's timeline.