> 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

***
