---
title: "Get one document's own standalone knowledge graph"
---

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

# Get one document's own standalone knowledge graph

Path: CloudRaker Workspace API › Ontology

`GET /spaces/{spaceId}/ontology/files/{fileId}/graph`

Returns `{ entities, edges }` for the document-scoped graph of a single `:fileId` — the entities and relations extracted from that one file, in the same shape as the space graph. Requires `space:read` on `:spaceId`; additionally the file must belong to `:spaceId` or the response is a 404. Missing `space:read` also surfaces as a 404.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`getFileOntologyGraph.path.spaceId`; string, required)
- `fileId` (`getFileOntologyGraph.path.fileId`; string, required)

## Code samples

### cURL

```bash
curl --request GET \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/ontology/files/<fileId>/graph' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/ontology/files/<fileId>/graph';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/spaces/<spaceId>/ontology/files/<fileId>/graph"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

The document's own graph.

#### Example

```json
{
  "entities": [
    {
      "id": "string",
      "type": "organization",
      "name": "Acme Inc",
      "key": "string",
      "mentionCount": -9007199254740991
    }
  ],
  "edges": [
    {
      "sourceId": "string",
      "targetId": "string",
      "relation": "employed_by",
      "fileId": "string"
    }
  ]
}
```

- `entities` (`getFileOntologyGraph.response.200.entities`; array<object>, required)
  - `id` (`getFileOntologyGraph.response.200.entities.id`; string, required)
  - `type` (`getFileOntologyGraph.response.200.entities.type`; string, required)
    - example `"organization"`
  - `name` (`getFileOntologyGraph.response.200.entities.name`; string, required)
    - example `"Acme Inc"`
  - `key` (`getFileOntologyGraph.response.200.entities.key`; string | null, required) — Normalized dedupe key.
  - `mentionCount` (`getFileOntologyGraph.response.200.entities.mentionCount`; integer, required)
    - min -9007199254740991; max 9007199254740991
- `edges` (`getFileOntologyGraph.response.200.edges`; array<object>, required)
  - `sourceId` (`getFileOntologyGraph.response.200.edges.sourceId`; string, required)
  - `targetId` (`getFileOntologyGraph.response.200.edges.targetId`; string, required)
  - `relation` (`getFileOntologyGraph.response.200.edges.relation`; string, required)
    - example `"employed_by"`
  - `fileId` (`getFileOntologyGraph.response.200.edges.fileId`; string, required) — The file the relation was observed in.


Source: https://docs.cloudraker.com/workspace/api/ontology/get-file-ontology-graph/index.md
