# Export Content with Entity Annotations

## User Intent

"How do I export content with entity annotations? Show me export formats with entity metadata."

## Operation

**SDK Methods**: `getContent()`, `queryContents()` for export\
**Format**: JSON export with entity data\
**Use Case**: Data export with entity annotations

## Prerequisites

* Content with extracted entities
* Export destination (file, database)
* Understanding of entity structure

***

## Complete Code Example (TypeScript)

```typescript
import { Graphlit } from 'graphlit-client';
import * as fs from 'fs';

const graphlit = new Graphlit();

// Get content with entities
const content = await graphlit.getContent('content-id');

// Prepare export data
const exportData = {
  id: content.content.id,
  name: content.content.name,
  type: content.content.type,
  creationDate: content.content.creationDate,
  text: content.content.markdown,
  
  entities: content.content.observations?.map(obs => ({
    type: obs.type,
    name: obs.observable.name,
    id: obs.observable.id,
    occurrences: obs.occurrences?.map(occ => ({
      confidence: occ.confidence,
      pageIndex: occ.pageIndex,
      boundingBox: occ.boundingBox,
      startTime: occ.startTime,
      endTime: occ.endTime
    }))
  })) || []
};

// Export as JSON
fs.writeFileSync('export.json', JSON.stringify(exportData, null, 2));
console.log('Exported with entity annotations');

// Export as CSV (flattened)
const csvRows = [
  ['Entity Type', 'Entity Name', 'Confidence', 'Page', 'Document'].join(',')
];

content.content.observations?.forEach(obs => {
  obs.occurrences?.forEach(occ => {
    csvRows.push([
      obs.type,
      obs.observable.name,
      occ.confidence.toFixed(2),
      occ.pageIndex?.toString() || '',
      content.content.name
    ].join(','));
  });
});

fs.writeFileSync('export.csv', csvRows.join('\n'));
console.log('Exported as CSV');
```

***

## Export Formats

### JSON (Full Fidelity)

Complete entity data with occurrences

### CSV (Tabular)

Flattened for spreadsheet analysis

### XML (Structured)

Hierarchical entity annotations

### Database (Structured Storage)

PostgreSQL, MongoDB for querying

***

## Use Cases

**Data Analysis**: Export for external tools\
**Backup**: Archive with entity data\
**Integration**: Feed to other systems\
**Reporting**: Generate entity reports\
**Training Data**: ML model training

***

## Developer Hints

* Include entity IDs for re-linking
* Preserve occurrence data (timestamps, pages)
* Export in batches for large datasets
* Compress for large exports
* Include metadata (dates, sources)

***


---

# Agent Instructions: 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/content-export-with-entities.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.
