9

I'm writing a webapp that uses the YouTube Code API to do specific types of searches. In this case, I'm trying to search for all videos that match a query, and which were uploaded between two dates. This document says I can use published-min and published-max parameters, while this one says I can use updated-min and updated-max.

Both of these parameter sets cause YouTube to return an error:

  • published-min returns "This service does not support the 'published-min parameter"
  • updated-min returns "This service does not support the 'updated-max' parameter"
  • With neither returns a correct result set.

How can I limit my result set to hits within a specified date range?

tsilb
  • 7,534
  • 13
  • 64
  • 94
  • FWIW, the API does seem to recognize the special filter values used in the regular YouTube search: `?q=Test%2C+today`, `?q=Test%2C+this+week`, `?q=Test%2C+this+month` – Joshua Carmody May 05 '11 at 20:27

2 Answers2

8

The Reference Guide for YouTube's Data API doesn't list anything that would suggest the possibility to filter on time interval in general.

The published-min argument is only advertised in the "User activity feeds" section which is something different and probably not the thing you wanted. Or is it?

The updated-min argument in your link is referenced in a generic gdata context. It looks like they intended to describe all the things common to all the specialized APIs, but somehow updated-min isn't available everywhere.

When it comes to your very problem. I would suggest sorting on time (orderby=published) and do the filtering on the client side. I know this is not the optimal way, but the only one I can see with what Google gives us.

Grzegorz Oledzki
  • 20,933
  • 15
  • 63
  • 94
  • 7
    As depressing as it is, that "solution" works. I hereby reprimand and scald YouTube for such a horrid implementation. In what universe can a database or API not be queried by entry date? :( – tsilb May 03 '11 at 06:05
  • YouTube API fails to execute with a start-index of 1000 or more. My sample data I'm using to target my search has a result set of 3300+ by one user. Any idea how to get around that little problem? – tsilb May 03 '11 at 06:14
  • I know it's even more stupid, but maybe there's some field which a closed set of values like `category` in which you could do the filtering separately and merge the results yourself? – Grzegorz Oledzki May 03 '11 at 11:29
  • 2
    Anyway, I suggest filing some request/complaint to them. Maybe someday someone will do something about it. I believe http://code.google.com/p/gdata-issues/ is the right place to do it. – Grzegorz Oledzki May 03 '11 at 11:30
4

youtube api v3 supports publishedAfter and publishedBefore parameters with search results. For example:

https://www.googleapis.com/youtube/v3/search?key={{YOUKEY}}&channelId={{CHANNELID}}&part=snippet,id&order=date&maxResults=50&publishedAfter=2014-09-21T00:00:00Z&publishedBefore=2014-09-22T02:00:00Z
motatoes
  • 606
  • 7
  • 22
  • 1
    you should mind that whoever comes here, it is not real publish date. It is the content creation date which is really bothersome for some videos. – NONONONONO Jan 25 '19 at 04:55