The
search_after_date and search_before_date parameters allow you to restrict search results to a specific publication date range. Only results with publication dates falling between these dates will be returned.The search_recency_filter parameter provides a convenient way to filter results by predefined time periods (e.g., “day”, “week”, “month”, “year”) relative to the current date.Specific date filters must be provided in the “%m/%d/%Y” format (e.g., “3/1/2025”). Recency filters use predefined values like “day”, “week”, “month”, or “year”. All filters are optional—you may supply either specific dates or recency filters as needed.
Overview
Date and time filters for the Search API allow you to control which search results are returned by limiting them to specific time periods. There are two types of date and time filters available:Publication Date Filters
Thesearch_after_date and search_before_date parameters filter results based on when content was originally created or published. This is useful when you need to:
- Find content published within a specific timeframe
- Exclude outdated or overly recent publications
- Focus on content from a particular publication period
Search Recency Filter
Thesearch_recency_filter parameter provides a simple way to filter results by predefined time periods relative to the current date. This is useful when you need to:
- Find content from the past day, week, month, or year
- Get recent results without specifying exact dates
- Quickly filter for timely information
"day"- Content from the past 24 hours"week"- Content from the past 7 days"month"- Content from the past 30 days"year"- Content from the past 365 days
Examples
1. Limiting Results by Publication Date Range This example limits search results to content published between March 1, 2025, and March 5, 2025. Request Examplesearch_after_date:
search_recency_filter provides a convenient way to filter results by predefined time periods without specifying exact dates:
Parameter Reference
search_after_date
- Type: String
- Format: “%m/%d/%Y” (e.g., “3/1/2025”)
- Description: Filters search results to only include content published after this date
- Optional: Yes
- Example:
"search_after_date": "1/1/2025"
search_before_date
- Type: String
- Format: “%m/%d/%Y” (e.g., “3/1/2025”)
- Description: Filters search results to only include content published before this date
- Optional: Yes
- Example:
"search_before_date": "12/31/2025"
search_recency_filter
- Type: String
- Allowed Values: “day”, “week”, “month”, “year”
- Description: Filters search results to content from the specified time period relative to the current date
- Optional: Yes
- Example:
"search_recency_filter": "week"
Best Practices
Date Format- Strict Format: Dates must match the “%m/%d/%Y” format exactly. For example, “3/1/2025” or “03/01/2025” is acceptable.
- Consistency: Use one or both date filters consistently based on your search needs. Combining both provides a clear range.
- Choose the Right Filter Type: Use publication date filters (
search_after_date/search_before_date) when you care about when content was originally created. Use recency filters (search_recency_filter) for quick, relative time filtering. - Recency vs. Exact Dates: Use
search_recency_filterfor convenience when you want recent content (e.g., “past week”). Use specific date filters when you need precise control over the time range. - Filter Limitations: Note that
search_recency_filtercannot be combined with specific date filters (search_after_date/search_before_date).
- Regex Check: Validate date strings on the client side using a regex such as:
- Narrowing the Search: Applying date range filters typically reduces the number of results, which may improve response times and result relevance.
- Avoid Over-Restriction: Ensure that the date range is neither too narrow (limiting useful results) nor too broad (defeating the purpose of the filter).
Advanced Usage Patterns
Finding Breaking News Use thesearch_recency_filter with “day” to find the most recent breaking news: