Alex
Alex

Reputation: 398

YouTube API "published" filter doesn't seem to work

I'm trying to use the YouTube API to return videos that were recently published, but the filter I'm using doesn't seem to work as expected.

This API call only returns two videos whereas there should be tons more that were published after March 1st:

https://gdata.youtube.com/feeds/api/videos?q=&fields=entry[xs:dateTime(published)%20%3E%20xs:dateTime('2013-03-01T12:00:00.000Z')]

However, if I add a query string, then many more results are returned. For example:

https://gdata.youtube.com/feeds/api/videos?q=surfing&fields=entry[xs:dateTime(published)%20%3E%20xs:dateTime('2013-03-01T12:00:00.000Z')]

Anyone know why? Is there another approach I should be using to just get me the latest videos published regardless of query string?

Upvotes: 0

Views: 531

Answers (1)

Jeff Posnick
Jeff Posnick

Reputation: 56034

I understand your confusion, but that's not what the fields= parameter is used for. The documentation should hopefully clear things up, but to summarize, using fields= in that manner is equivalent to making a request without the fields= parameter and then filtering the results of that request so that it only includes the entries that match your filter.

So if your request without fields= would normally return 25 specific videos, adding fields= to it will give you a response that includes somewhere between 0 and 25 videos—all the non-matching videos are filtered out.

You can request a feed of recently published videos without any other filters using http://gdata.youtube.com/feeds/api/videos?v=2&orderby=published

Upvotes: 1

Related Questions