---
title: "Get a space's entity/relation 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 a space's entity/relation knowledge graph

Path: CloudRaker Workspace API › Ontology

`GET /spaces/{spaceId}/ontology`

Returns the whole knowledge graph extracted from the documents in a space: `{ entities, edges }`. Each entity has `id`, `type` (one of organization | person | location | identifier | date | amount | other), `name`, `key`, and `mentionCount`; each edge has `sourceId`, `targetId`, `relation`, and the `fileId` it was observed in. Optional `?limit=` (1-2000) caps the number of entities returned. Requires `space:read` on `:spaceId` — a caller lacking it gets a 404 (existence is hidden).

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`getSpaceOntology.path.spaceId`; string, required)

## Query parameters

- `limit` (`getSpaceOntology.query.limit`; integer, optional) — Maximum entities returned, 1–2000. There is no cursor.
  - min 1; max 2000; default `500`

## Code samples

### cURL

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

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/ontology';
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"

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

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

print(response.text)
```

## Responses

### 200

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


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