---
title: "Walk the graph outward from an entity in a space"
---

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

# Walk the graph outward from an entity in a space

Path: CloudRaker Workspace API › Ontology

`GET /spaces/{spaceId}/ontology/entities/{entityId}/related`

Returns the neighbourhood of an entity: `{ entities, edges }` reachable within `?depth=` hops (1-3, default 1). Each neighbour entity carries `id`, `type`, `name`, and `distance` (hop count from the seed); edges carry `sourceId`, `targetId`, `relation`, `fileId`. Use it to expand context around a match. Requires `space:read` on `:spaceId`; missing access surfaces as a 404.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`getSpaceOntologyRelatedEntities.path.spaceId`; string, required)
- `entityId` (`getSpaceOntologyRelatedEntities.path.entityId`; string, required)

## Query parameters

- `depth` (`getSpaceOntologyRelatedEntities.query.depth`; integer, optional) — Hops to walk, 1–3.
  - min 1; max 3; default `1`

## Code samples

### cURL

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

### TypeScript

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

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

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

print(response.text)
```

## Responses

### 200

Neighbouring entities and the connecting edges.

#### Example

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

- `entities` (`getSpaceOntologyRelatedEntities.response.200.entities`; array<object>, required)
  - `id` (`getSpaceOntologyRelatedEntities.response.200.entities.id`; string, required)
  - `type` (`getSpaceOntologyRelatedEntities.response.200.entities.type`; string, required)
    - example `"organization"`
  - `name` (`getSpaceOntologyRelatedEntities.response.200.entities.name`; string, required)
  - `distance` (`getSpaceOntologyRelatedEntities.response.200.entities.distance`; integer, required) — Hops from the seed entity.
    - min -9007199254740991; max 9007199254740991
- `edges` (`getSpaceOntologyRelatedEntities.response.200.edges`; array<object>, required)
  - `sourceId` (`getSpaceOntologyRelatedEntities.response.200.edges.sourceId`; string, required)
  - `targetId` (`getSpaceOntologyRelatedEntities.response.200.edges.targetId`; string, required)
  - `relation` (`getSpaceOntologyRelatedEntities.response.200.edges.relation`; string, required)
    - example `"employed_by"`
  - `fileId` (`getSpaceOntologyRelatedEntities.response.200.edges.fileId`; string, required) — The file the relation was observed in.


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