Learn how to filter your search results by their publication date and time
published_date
. Using this
information you can further drill down in your search queries on the
v2/search
and
v2/latest_headlines
endpoints.
/search
/search
endpoint has two parameters, to
and from
, that enable you to
filter your news search results by their publication dates.
Let’s say, you want to understand the general perception of the new Tesla UI
update. To achieve this you’ll need to fetch the articles published around the
time the update was pushed to the cars. If you decide on the date range of
2021/12/01 to 2022/31/01, you would use the to
and from
parameters to
make a request like*:*
to
and from
parameters is UTC._2021/07/18_
, as opposed to
'7 months and 27 days ago'
. And if you want to specify the time, things get
even more complicated.
published_date_precision
attribute. There are three types of date precision
defined in our News API:
"full"
— day and time of an article is correctly identified with the
appropriate timezone"timezone unknown"
— day and time of an article is correctly
identified without timezone"date"
— only the day is identified without an exact timeDistribution of `published_date_precision` attribute
/latest_headlines
/latest_headlines
endpoint doesn’t have the to
and from
parameters.
Instead, it has the when
parameter that dictates the time period starting from
which you want to get the articles for. It accepts two forms:
Xd
7d
=> last 7 days time periodXh
24h
=> last 12 hours12h
will yield
more and older results than a request for articles from the last one hour 1h
.