> For the complete documentation index, see [llms.txt](https://docs.graphlit.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlit.dev/api-guides/use-cases/knowledge-graph/observable-content-timeline.md).

# Entity Mention Timeline

## User Intent

"When was this entity first/last mentioned? Show me a timeline of entity mentions."

## Operation

**SDK Method**: `queryContents()` with entity filter and date sorting\
**GraphQL**: Timeline queries\
**Use Case**: Track entity mentions over time

## Prerequisites

* Content with entities and dates
* Entity to track
* Understanding of date filtering

***

## Complete Code Example (TypeScript)

```typescript
import { Graphlit } from 'graphlit-client';
import { ObservableTypes } from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Find entity
const entity = await graphlit.queryObservables({
  search: "Graphlit",
  filter: { types: [ObservableTypes.Organization] }
});

const entityId = entity.observables.results[0]?.observable.id;

// Get mentions sorted by date
const mentions = await graphlit.queryContents({
  
    observations: [{
      observable: { id: entityId }
    }]
  
  orderBy: { creationDate: 'ASCENDING' }
});

// First and last mentions
const first = mentions.contents.results[0];
const last = mentions.contents.results[mentions.contents.results.length - 1];

console.log(`First mention: ${new Date(first.creationDate).toLocaleDateString()}`);
console.log(`Last mention: ${new Date(last.creationDate).toLocaleDateString()}`);

// Group by month
const byMonth = new Map<string, number>();
mentions.contents.results.forEach(content => {
  const month = content.creationDate.substring(0, 7);  // YYYY-MM
  byMonth.set(month, (byMonth.get(month) || 0) + 1);
});

console.log('\nMentions by month:');
Array.from(byMonth.entries())
  .sort((a, b) => a[0].localeCompare(b[0]))
  .forEach(([month, count]) => {
    console.log(`  ${month}: ${count}`);
  });
```

***

## Key Patterns

### 1. First/Last Mention

```typescript
orderBy: { creationDate: 'ASCENDING' }  // or 'DESCENDING'
```

### 2. Time Range

```typescript
filter: {
  creationDateRange: {
    from: '2024-01-01',
    to: '2024-12-31'
  }
}
```

### 3. Activity Trends

Group by period and count mentions

***

## Use Cases

**Entity Lifecycle**: Track when entity appears\
**Trending Analysis**: Rising/falling mentions\
**Event Detection**: Spikes in mentions\
**Historical Research**: Entity history\
**Activity Monitoring**: Real-time tracking

***

## Developer Hints

* Use creationDate for timelines
* Aggregate for trends
* Visualize with charts
* Alert on spikes
* Cache timeline data

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.graphlit.dev/api-guides/use-cases/knowledge-graph/observable-content-timeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
