Constrain results by date in get_everything
masterThe get_everything method accepts from_param and to parameters to filter articles by publication date. You can provide these values in several formats:
datetime.dateobjectsdatetime.datetimeobjects (assumed to be in UTC)strformatted as%Y-%m-%d(e.g.,2019-09-07) or%Y-%m-%dT%H:%M:%S(e.g.,2019-09-07T13:04:15)intorfloat(representing a Unix timestamp)None(the default, which applies no constraint)
import datetime as dt
# Using datetime.date
api.get_everything(
q="hurricane",
from_param=dt.date(2019, 9, 1),
to=dt.date(2019, 9, 3),
)
# Using datetime.datetime
api.get_everything(
q="hurricane",
from_param=dt.datetime(2019, 9, 1, hour=5),
to=dt.datetime(2019, 9, 1, hour=15),
)
# Using ISO strings
api.get_everything(
q="hurricane",
from_param="2019-08-01",
to="2019-09-15",
)
# Using full ISO datetime strings
api.get_everything(
q="venezuela",
from_param="2019-08-01T10:30:00",
to="2019-09-15T14:00:00",
)