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

# Causality Graph

> Best practices for Causality Graph

## Use URLs with analytical or causal content

URLs pointing to research reports, news articles, or policy documents with explicit cause-and-effect language (e.g., "leads to", "causes", "results in") produce richer and more accurate graphs.

```json theme={null}
{ "url": "https://imf.org/en/Publications/WEO" }
```

For documents you have locally, use the `/api/v1/causality-graph/file` endpoint instead.

```bash theme={null}
curl -X POST "https://api.factagora.com/api/v1/causality-graph/file" \
  -H "Authorization: Bearer fag_your_api_key" \
  -F "file=@analysis.pdf"
```

## Visualize as a directed graph

The `edges` array is directional: `from` is the cause, `to` is the effect. Use this to render a DAG (directed acyclic graph) in your UI.

```javascript theme={null}
edges.forEach(edge => {
  graph.addEdge(edge.from, edge.to, { label: edge.label });
});
```

## Filter isolated nodes

Nodes without any edges are likely extraction artifacts. Filter them out before rendering.

```javascript theme={null}
const connectedNodeIds = new Set([
  ...edges.map(e => e.from),
  ...edges.map(e => e.to),
]);
const filteredNodes = nodes.filter(n => connectedNodeIds.has(n.id));
```

## Combine with Timeseries

Use Causality Graph alongside [Timeseries](/api-reference/timeseries) to answer both "what happened?" and "why did it happen?".

```
Timeseries (what happened) → Causality Graph (why it happened)
```
