> ## 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

> 주어진 URL이나 파일에서 인과 관계를 분석해 구조화된 인과 그래프를 반환

URL 또는 업로드된 파일(PDF, Markdown)에서 인과 관계를 분석합니다. 노드(개념/이벤트)와 방향성을 가진 간선(인과 관계)을 반환하여 원인-결과 체인을 시각화하는 데 사용할 수 있습니다.

## 엔드포인트

| 메서드 | 경로 | 입력 |
| - | - | - |
| `POST` | `/api/v1/causality-graph` | `url`을 포함한 JSON 본문 |
| `POST` | `/api/v1/causality-graph/file` | `file`을 포함한 `multipart/form-data` |

***

## POST /api/v1/causality-graph

### 요청 본문

**url** `string` *required*

인과 관계를 추출할 페이지 또는 문서 URL.

**language** `string`

추출된 노드 및 엣지 label의 언어 (예: `english`, `korean`). 노드 `id`는 그래프 무결성을 위해 영어/ASCII로 유지됩니다. 기본값: 영어.

**limit** `number` (default: 30)

추출할 노드의 최대 개수. 범위: 1–100. 엣지 개수는 노드 개수에 따라 자연스럽게 제한됩니다.

```bash cURL theme={null}
curl -X POST "https://api.factagora.com/api/v1/causality-graph" \
  -H "Authorization: Bearer fa_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/economic-analysis"}'
```

```python Python theme={null}
resp = requests.post(
    "https://api.factagora.com/api/v1/causality-graph",
    headers={"Authorization": "Bearer fa_your_api_key"},
    json={"url": "https://example.com/economic-analysis"},
)
graph = resp.json()
```

```typescript TypeScript theme={null}
const resp = await fetch("https://api.factagora.com/api/v1/causality-graph", {
  method: "POST",
  headers: {
    Authorization: "Bearer fa_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ url: "https://example.com/economic-analysis" }),
});
const graph = await resp.json();
```

***

## POST /api/v1/causality-graph/file

### 요청 본문 (multipart/form-data)

**file** `file` *required*

인과 관계를 추출할 PDF 또는 Markdown 파일.

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

***

## 응답

**nodes** `array`

그래프 내 개념 또는 이벤트 노드 목록입니다.

**Node fields**

**id** `string`

고유 노드 식별자

**label** `string`

노드의 사람이 읽을 수 있는 라벨

**edges** `array`

노드 간 방향성을 가진 인과 관계 목록입니다.

**Edge fields**

**from** `string`

출발 노드 ID (원인)

**to** `string`

도착 노드 ID (결과)

**label** `string`

관계에 대한 선택적 설명

**meta** `object`

**Meta fields**

**total\_nodes** `number`

전체 노드 수

**total\_edges** `number`

전체 간선 수

**executionTimeMs** `number`

응답 시간(밀리초)

```json 200 theme={null}
{
  "nodes": [
    { "id": "n1", "label": "Rising interest rates" },
    { "id": "n2", "label": "Lower consumer spending" },
    { "id": "n3", "label": "Reduced GDP growth" },
    { "id": "n4", "label": "Higher unemployment" }
  ],
  "edges": [
    { "from": "n1", "to": "n2", "label": "causes" },
    { "from": "n2", "to": "n3", "label": "leads to" },
    { "from": "n3", "to": "n4", "label": "leads to" }
  ],
  "meta": {
    "total_nodes": 4,
    "total_edges": 3,
    "executionTimeMs": 640
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.