Using YouTube API, is it possible to filter search by upload date? - youtube-api

I'm working on a personal project to retrieve YouTube videos on a particular subject very quickly after they are posted. Using the "Sort By" filter works well, however, I've noticed that some videos that fit the search query do not appear in the HTML. So, I was wondering if it is possible to also sort by Upload date, similar to the YouTube feature which allows for filtering videos based on if they were posted in the last hour, today, this week, etc. I believe that if I could include a filter for videos posted in the last hour, that would improve the accuracy of my project.
Any help is very much appreciated.

Check out the "order" parameter in this API (can set it to "date").

Related

YouTube API is not giving accurate video results

Getting video in the results even though it didn't match query parameter(q)
The parameter i passed didn't exists in body,title,tags, But the video is relavant. Is API looks any other metadata of video.
For Example: i have given parameter as "mobile", this video https://www.youtube.com/watch?v=j8UNo3vRIB0 is coming as result, here video title and description not contain mobile as parameter
Latest data not coming consistently in youtube api
Some times latest data not coming in youtube data api.
For Example: i have given rule as "amazon". This video https://www.youtube.com/watch?v=6zygd1iW-f4 is showing in youtube website's latest videos but not coming in youtube api result.
Example query: https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&q=amazon&maxResults=50&type=video&key=xyz
W.r.t. point (1), Youtube is working OK, since the content of that video is related to the keyword mobile (please convince yourself by watching the first couple of minutes of that video).
For what concerns your point (2), I cannot in any way make the Youtube site to produce the video 6zygd1iW-f4 near the top of its search result set for the query term amazon.
All in all, I deem your claims above unsustainable.
Please note that one cannot expect crisp results from Youtube when queried with such general terms as yours is. One should not expect Youtube's searching feature to work similarly to say a full-text search in single computer-stored database. There will always be a degree of fuzziness associated to querying Youtube for broad terms.
You are actually stumbling on a very tricky scenario. Your goal is to get the same results via the API that you also see on YouTube’s website, right?
First, make sure that you configured the search endpoint as identical to your YouTube user account as possible:
order: relevance
relevanceLanguage: Same as the language that you set in the menu of YouTube’s website (Use a ISO 639-1 2-letter Code)
regionCode: Same as the country that you set in the menu of YouTube’s website (Use a ISO 3166-1 2-letter Code)
With these settings you will see that the results will be quite similar. But still not identical. Not because the API is not working or is still not properly configured but rather because YouTube’s search results change all the time. Just do the same exact search on YouTube’s website just 10 seconds apart. You’ll see that you get different search results.

Is there a way to search for old tweets on a specific date using a specific hashtag?

For example how could search for tweets using the #oldtweets sent on 5-29-16, from 8pm to 9pm.
According to the The Twitter Search API documentation, the query you want is not possible: https://dev.twitter.com/rest/public/search
The Twitter Search API searches against a sampling of recent Tweets
published in the past 7 days.
Beyond the last 7 days, what you want to achieve can only be done through manually searching an account on Twitter.
Another alternative would be to use https://webrecorder.io/
Scroll to the timeframe you want to record or you can attempt to capture the entire feed. Note the auto scrolling option as well.

YouTube API "mostPopular" requests doesn't seem to give updated results

It seems that the YouTube API doesn't give updated results for mostPopular videos in my country since few days.
Example:
This request (https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&chart=mostpopular&regionCode=FR) doesn't give me the same videos results than the ones displayed directly on YouTube for the French most popular channel (https://www.youtube.com/channel/UCmzy72gDEpfXoFV9Xdtd0DQ). It seems that the results of this request is not updated since the 1th of february. Results was real time updated before this.
Does someone know if something is wrong with my API request, or if there are some issues with the YouTube API at this moment?
There is nothing wrong with your request. This is a known issue with the YouTube API reported here for Saudi Arabia (but also applicable to multiple regions), and another related issue here with regard to content from France.
Your best bet would be to follow up with the YouTube team on one of those defects, or potentially (and dangerously) scrape the YouTube site for the correct results.
Problem seems to be solved since 13th of february (maybe someone from Google have seen my post..)
YouTube Channels and chart=mostPopular parameter data are separate data entities, aka you will get different results. They may be related but there is no guarantee you will get the same data. To get the data that you want you may need to query for channel itself and its videos.
I got this information from the thread #Jal linked, there was an update by matthewc...#google.com a few days ago:
The most popular channel for Saudia
Arabia and
the mostPopular chart parameter in the video.list
call
are separate and distinct entities. If you'd like to get the content
of the most popular channel for Saudia
Arabia
please use the Data API video.list call to list the videos with the
channel ID (in this case "UCWY-_j1MCth6yf24m58Bh_Q") by setting the
items/snippet/channelId parameter.
My current concern right now is that there is supposedly a way to get video information from the videos.list endpoint using a channelId, which does not seem the case in the API Explorer. I will update my answer once I figure out what this person meant exactly.

Get Instagram media with a specific tag in specific time period

I am in a situation where I need to get all the photos posted to instagram with a particular tag in a specific time period. Basically, I want to show all the images those were posted in between certain time period (Probably dates). But as of now I can't see any option that is being provided in the instagram tags api.
I have tried using the same api to get the photos and loop through it with a condition to check the created_time. But I found that the response is not ordered by created_time. Is there any way I can achieve the same, Any help would be appreciated.
Currently there is no option to do this. Other APIs have max_timestamp and min_timestamp options, but tag media endpoint does not have this option.

What is the easiest way to get the latest comment on any of my videos, using v2 of the YouTube API?

As pointed out in the question How do I fetch comments in version 3 of the YouTube API?, there is currently no way of fetching video comments using version 3 of the YouTube API. Now I'm trying to figure it out using version 2 instead.
What I want is the latest comment on any of my uploaded videos, in other words the latest comment in the "aggregated" comment feed of all my videos.
It seems like the only way to do this is too fetch all videos, and then make a call for each of them to get the comments. With a few hundred uploaded videos, this becomes very expensive in terms of number of API calls and total time for completion.
Is there a simpler and/or better way?
There's no way to be "notified" via the API when a video gets a new comment, so you're going to have to do some polling. The comments feed for a given video id, e.g. https://gdata.youtube.com/feeds/api/videos/fhWaJi1Hsfo/comments?v=2 for video id fhWaJi1Hsfo, is sorted in reverse-chronological order by default, so the last comment added should always be first in the list of entries.
Making a request for the comments feed of several hundred videos, even if you do that a couple of times a day, doesn't sound like an unreasonable amount of traffic. You should follow the best practices outlined in this blog post if you do run into any quota issues, though.

Resources