# Create neighbors

URL: https://docs.hanzo.ai/docs/openapi/graph/graphneighbors

> Walks the in-force edges from a set of seeds and lists every entity reached, bounded.

`POST /v1/graph/neighbors`

> [Graph →](https://docs.hanzo.ai/docs/openapi/graph) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                           |
| ------------- | ----------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/graph/neighbors` |
| **Method**    | `POST`                                    |
| **Operation** | `graphNeighbors`                          |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`    |

Walks the in-force edges from a set of seeds and lists every
entity reached, bounded.

Only the edge that holds at the point is a hop: a superseded or retracted
edge is not, and neither is a property.

Time: as\_of walks the graph as it stood at that instant and as\_known as this
plane knew it then; either absent is now.

## Request

6 fields, body `application/json` (required).

| Field       | In   | Type            | Required | Description                                                                                                                                      |
| ----------- | ---- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `as_known`  | body | string          | —        | AsKnown is how much this plane had heard, RFC 3339: the answer as it would have been given then, which is what makes a past answer reproducible. |
| `as_of`     | body | string          | —        | AsOf walks the graph as it stood at an instant of the world, RFC 3339: the edges that held then.                                                 |
| `depth`     | body | integer (int64) | —        | Depth is how many hops.                                                                                                                          |
| `direction` | body | string          | —        | Direction is out, in or both.                                                                                                                    |
| `relation`  | body | string          | —        | Relation narrows the walk to one edge relation.                                                                                                  |
| `seeds`     | body | string\[]       | yes      | Seeds is where the walk starts.                                                                                                                  |

## Response

| Status    | Body                    | Meaning |
| --------- | ----------------------- | ------- |
| `200`     | graph.graphNeighborsOut | ok      |
| `default` | problem-details         | refused |

`200` body — 4 fields.

| Field       | In   | Type            | Always | Description                                                                                                                              |
| ----------- | ---- | --------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `bound`     | body | integer (int64) | —      | Bound is the ceiling this walk was held to, the same for every caller, so Truncated can be read against a number rather than guessed at. |
| `depth`     | body | integer (int64) | —      | Depth is the deepest hop count actually reached.                                                                                         |
| `entities`  | body | string\[]       | —      | Entities is everything reached, the seeds included, ordered by the fewest hops that reach each one and then by key.                      |
| `truncated` | body | boolean         | —      | Truncated says the bound stopped the walk.                                                                                               |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo graph neighbors
```

**SDK**

**.ts**

```ts
import { Configuration, GraphApi } from 'hanzoai';

const api = new GraphApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.graphNeighbors({ seeds: ["<seeds>"] });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import GraphApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = GraphApi(client).graph_neighbors(seeds=["<seeds>"])
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.GraphAPI.GraphNeighbors(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, graph_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = graph_api::graph_neighbors(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.GraphApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new GraphApi(client).graphNeighbors();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/graph/neighbors \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "seeds": [
         "<seeds>"
       ]
     }'
```

**MCP**

Tool `graph`, op `graphNeighbors` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "graph",
         "arguments": {
           "op": "graphNeighbors",
           "input": {
             "seeds": [
               "<seeds>"
             ]
           }
         }
       }
     }'
```

---

[Graph API](https://docs.hanzo.ai/docs/openapi/graph) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
