Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Read Recall for how querying memory works
- No data is required up front — the script ingests its own dated sample text, but it starts with
cognee.forget(everything=True), which wipes all existing Cognee data; run it against a setup you can afford to reset
Code in Action
What Just Happened
Step 1: Remember Data with Temporal Mode
TEXT into the timeline_demo dataset. Because temporal_cognify=True, remember() extracts events and timestamps and builds the timeline during ingestion, so there is no separate cognify() step. This example uses one string treated as a single document; multiple documents, files, or entire datasets are processed the same way.
Step 2: Ask Time-aware Questions
SearchType.TEMPORAL, imported from the cognee package at the top of the script. Each call is scoped with datasets=["timeline_demo"] so it only searches the timeline it just ingested; drop the argument to search every dataset you have access to. The answer for each query is results[0].text.
How Events and Timestamps Are Stored
Temporal ingestion adds three DataPoint types to the graph:
An event is anything that happened in time: a dated milestone, but also any action or verb in the text — so a few sentences typically yield many events. Each extracted event is attached to its source chunk through the chunk’s
contains edge, and the entities mentioned in it become Entity nodes linked to the event by the relationship the extractor found (for example transferred_to).
How time attaches depends on what the text gives:
- A single moment → the event points at one
Timestampnode throughat. - A span → the event points at an
Intervalthroughduring, and the interval points at a start and an endTimestamp. - Only the year is mandatory in a timestamp. Unknown month and day default to
1, and unknown hour, minute, and second to0, so"In 2001 version 1.0 shipped"is stored as2001-01-01 00:00:00. - A
Timestampnode’s id is derived from itstime_atvalue, so every event resolving to the same instant shares one timestamp node. Resolved times are also appended to the event description as aTime data: ...line, which is what the answer is generated from.
Timestamp nodes whose time_at falls inside it, and collects the events within two hops of those nodes — one hop for at, two for during. Those candidates are then ranked by embedding similarity to your query and cut to top_k.
Relative and vague time expressions
Extraction only timestamps events it can place on a calendar. A phrase such as “when I was young, I loved running” or “when I was at primary 2, I transferred school” still produces anEvent node with its entities and its chunk link, but with no at or during — and therefore no Timestamp node:
- The event remains fully retrievable through event and entity search, including the fallback path inside
SearchType.TEMPORAL. - It is invisible to time-range filtering, so a “before 2005” query will not surface it.
Using the HTTP API
If your server is running, you can run temporal search via the API by settingsearch_type to "TEMPORAL":
The Python example above is still the easiest way to enable temporal ingestion because it lets you pass
temporal_cognify=True directly to remember().Full Examples
Additional examples about temporal awareness are available on our GitHub.- An advanced script running temporal search over real documents is on our GitHub. Instead of the inlined four-sentence timeline above, it ingests two bundled biographies as separate documents with
temporal_cognify=True, then mixes before / after / between range queries with person-centric questions that carry no dates — exercising the entity-retrieval fallback described in the tip above.
Legacy guide
Legacy guide
Fact Validity
Close superseded facts and check staleness with is_valid()
Core Concepts Overview
Understand how Cognee builds and stores knowledge graphs.
API Reference
Explore the search endpoint behind temporal queries.