Can we date bound the Tavily API like we do for days while using topic="news"?

As in the question, I am looking to date bound the search API to return results from a particular range, and days doesn’t have that level of control over my workflow.

Would really appreciate help on this.

Hi,

Thank you for reaching out! That does sound like a very useful feature. However, currently, our API does not support date-bound filtering for the topic=“news” queries. You can filter by “days,” but there’s no direct way to specify a custom date range at the moment.

We appreciate your feedback and will consider this for future updates!

Best,
May

+1 to this question. I am building an AI financial agent and it would be very helpful to date-bound the filtering at the API level, especially for things like sentiment analysis.

Concrete example: I have a backtester that calls the API repeatedly over a date range (e.g. Jan 2023 and March 2023). I would like to get the news sentiment between that date range only for my AI agent to do sentiment anlaysis.

This feature would be huge.

2 Likes

Hey Virat, been following your work on Twitter.

One hack that I found is passing your Datetime in the search query and making the search_depth=“general”, the results were pretty promising.

search_query = f"{index_name} {date_str} India financial news"
domain_results = tavily_client.search(
                search_query,
                topic="general",
                search_depth="advanced",
                max_results=3,
                include_answer=True,
                include_raw_content=True,
                include_domains=[domain]
            )

Just adding that I would also love to see the “date” filter on the general search. We are using Tavily in a company research use case and “news” has the date filter but the news results typically don’t pick up announcements on company blogs and return low-relevancy results from mainstream news sites instead.

1 Like

+1, would also be super helpful to benchmark systems with tavily included, as it would keep the results tavily is returning consistent for a query.

1 Like

Hey all! we’ve added a time_range argument that allows you to specify a time range, going back from the current date, to include in the search results. Accepted values include "day", "week", "month", "year", or their shorthand versions: "d", "w", "m", "y". The default is None, which will not filter search results by time range.

Note that time_range argument is available for both the “general” and “news” topics, while the days argument is exclusive to topic="news" and allows you to specify an exact number of days from the current date to include in the results.

We hope this is useful! Let us know if you have any questions or feedback.

1 Like

awesome @maitar - thanks for following up! Can’t wait to try it out

1 Like

@maitar Clarifying question: is the new feature just a day/week/etc back from the current date? Attributing a date to the results would also be a feature to consider…if I were searching for news for the last quarter or by quarter, I could do. “year” search and group the results by time period if I knew when each result was published.

Yes, the date filter works relative to the current date (you can filter by day, week, month, or year from today). We’ll consider adding more flexibility with date bounds in the future. In the meantime, we hope this is helpful and are happy to receive your feedback!

@maitar is it / will it be possible to have time_range more flexible, i.e. using expressions like 2w, 6m etc.?

Hi @Zohar, currently this isn’t supported, but we’re working on it and it’s on our roadmap. Stay tuned for updates!

That said, we do support it for topic="news" using the days parameter — for example, to filter for two weeks, you’d specify days=14

1 Like