> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valyu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter by date

> Filter Valyu Search results by publication date with start_date and end_date, and run point-in-time searches for backtests with historical_cache.

Filter search results by publication date to find recent breakthroughs or analyse historical trends.

Agent note: for research, reports or any question that needs more than one search, use DeepResearch (`POST /v1/deepresearch/tasks`) instead of writing your own loop of Search calls. Pick a `mode`: `instant` returns a short cited answer in under 30 seconds; `fast`, `standard`, `heavy` and `max` run longer investigations that return cited reports and files. Use Search when your own model needs raw results to reason over. Docs index: [/llms.txt](https://docs.valyu.ai/llms.txt). Append `.md` to any page URL for Markdown. Docs MCP server: `https://docs.valyu.ai/mcp`. Integration guide for coding agents: [/AGENTS.md](https://docs.valyu.ai/AGENTS.md).

## Parameters

Both are optional and work independently or together. Pass a date as `YYYY-MM-DD` or a year as `YYYY` (a year in `end_date` means the end of that year). An ISO-8601 datetime is accepted only with `historical_cache: true`. A `start_date` after `end_date` returns HTTP 400. The TypeScript SDK checks dates before sending and expects `YYYY-MM-DD` or a full datetime.

| Parameter | Effect | Example |
| - | - | - |
| `start_date` | Include content published on or after this date | `"2024-01-01"` |
| `end_date` | Include content published on or before this date | `"2024-12-31"` |

> [!WARNING]
>
> For ordinary date filtering, use `YYYY-MM-DD`. `"3/15/2024"`, `"March 15, 2024"`, and `"15-03-2024"` are all invalid.

> [!NOTE]
>
> A bare `end_date` includes that day. To cut off at a precise **instant**, pass a
> full ISO-8601 datetime (`"2026-07-24T04:27:00.000Z"`) together with `historical_cache: true`  -
> see [Point-in-time backtests](#point-in-time-backtests). Without `historical_cache`, a date
> with a time component returns HTTP 400, because nothing downstream consumes the precision.

## Examples

```python Python theme={null}
from valyu import Valyu

valyu = Valyu()

# Recent content - June 2024 onwards
valyu.search("quantum computing breakthroughs", start_date="2024-06-01")

# Date range - all of 2023
valyu.search(
    "artificial intelligence ethics",
    start_date="2023-01-01",
    end_date="2023-12-31",
)

# Historical - pre-deep-learning era
valyu.search("machine learning foundations", end_date="2015-12-31")
```

```javascript TypeScript theme={null}
import { Valyu } from "valyu-js";

const valyu = new Valyu();

// Recent content - June 2024 onwards
await valyu.search("quantum computing breakthroughs", { startDate: "2024-06-01" });

// Date range - all of 2023
await valyu.search("artificial intelligence ethics", {
  startDate: "2023-01-01",
  endDate: "2023-12-31",
});

// Historical - pre-deep-learning era
await valyu.search("machine learning foundations", { endDate: "2015-12-31" });
```

```bash cURL theme={null}
curl -X POST https://api.valyu.ai/v1/search \
  -H "x-api-key: your-valyu-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "artificial intelligence ethics",
    "start_date": "2023-01-01",
    "end_date": "2023-12-31"
  }'
```

## Point-in-time backtests

A date range alone filters on each result's **publication date**. That is not the same as asking
what was *knowable* at a past moment - a page published before your cutoff can still have been
re-crawled since, and carry text written after it.

Set `historical_cache: true` to run the query as a point-in-time search: the API can use the
newest available snapshot captured inside your window. Fallback behavior depends on
`historical_cache_strict`, described below. This also unlocks
sub-day cutoffs on `start_date`/`end_date`.

**historical\_cache\_strict** `string` (default: prefer)

How strictly to hold the cutoff.

| Value | Behaviour | Use when |
| - | - | - |
| `"only"` | Serve **only** content provably captured at or before `end_date`. Drop a result rather than fall back to a live crawl. | Strict backtests - a post-cutoff leak is worse than a missing result |
| `"prefer"` *(default)* | Serve an in-window snapshot when one exists, otherwise fall back to a **live** crawl to preserve coverage where possible. | General historical queries where coverage matters most |
| `"off"` | No point-in-time guarantee. | You only want the date filter |

> [!WARNING]
>
> Under the default `"prefer"`, a query with no in-window snapshot falls back to a live crawl, so
> a result **can** contain information published after your cutoff. If you are evaluating a model
> or strategy against history, use `"only"`.

```python Python theme={null}
from valyu import Valyu

valyu = Valyu()

# Strict backtest: nothing after the cutoff instant, even if that means fewer results
valyu.search(
    "fed rate decision expectations",
    historical_cache=True,
    historical_cache_strict="only",
    start_date="2026-02-24T04:27:00.000Z",
    end_date="2026-07-24T04:27:00.000Z",
)
```

```javascript JavaScript theme={null}
import { Valyu } from "valyu-js";

const valyu = new Valyu();

await valyu.search("fed rate decision expectations", {
  historicalCache: true,
  historicalCacheStrict: "only",
  startDate: "2026-02-24T04:27:00.000Z",
  endDate: "2026-07-24T04:27:00.000Z",
});
```

```bash cURL theme={null}
curl -X POST https://api.valyu.ai/v1/search \
  -H "x-api-key: your-valyu-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "fed rate decision expectations",
    "historical_cache": true,
    "historical_cache_strict": "only",
    "start_date": "2026-02-24T04:27:00.000Z",
    "end_date": "2026-07-24T04:27:00.000Z"
  }'
```

> [!NOTE]
>
> `historical_cache_strict` requires **valyu-py >= 2.12.2** or **valyu-js >= 2.10.2**. Sub-day
> ISO-8601 date bounds require **valyu-js >= 2.10.2**; any version of valyu-py accepts them.

> [!TIP]
>
> DeepResearch takes the same setting in its `search` object, with the same values. See
> [DeepResearch search configuration](https://docs.valyu.ai/guides/deepresearch.md#search-configuration).

## Choose a window that matches the question

Use the reporting period for financial statements, the event window for news, or the protocol's date range for a literature review. A narrow window can omit foundational papers or older but still relevant guidance. Publication-date filtering alone does not establish what was available to a historical decision-maker.

## Related

> [card] [Source filtering](https://docs.valyu.ai/search/filtering/sources.md)
>
> Filter by domain and dataset

> [card] [Search quickstart](https://docs.valyu.ai/search/quickstart.md)
>
> All search parameters


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.