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

# Asset Map

Use the SDK to explore your organization’s [Asset Map](/docs/asset-map), find assets, and follow their connections.

You can retrieve part of the graph as JavaScript objects or compose a Cypher query to select specific information. Both read the same map shown in the platform, using your API key’s organization.

| Method | Use it to |
| - | - |
| `antigen.assetMap.get()` | Retrieve assets and their connections as nodes and edges. |
| `antigen.assetMap.query()` | Filter assets, follow specific relationships, or aggregate results with Cypher. |

## How the graph is organized

Assets are represented as **nodes**. Each node has an ID, labels describing what it is, and properties containing its details.

A Supabase database, for example, has both `SupabaseDatabase` and `Database` labels. Its properties include its hostname and database version. These labels let you query a specific integration’s resources or work across integrations using a shared category.

**Edges** describe directed relationships between nodes. A `HAS_DATABASE` edge connects a Supabase project to its database. A `RESOURCE` edge connects an account or organization to the resources it contains.

The available labels, properties, and relationships depend on the integrations connected to your map.

## Retrieve assets and their connections

Call `antigen.assetMap.get()` with one or more asset IDs. Set `depth` to control how far to explore their connections.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Antigen from "@antigen/sdk";

const antigen = new Antigen(process.env.ANTIGEN_API_KEY);

const graph = await antigen.assetMap.get({
  nodeIds: ["project_123"],
  depth: 1,
});
```

This returns the selected project and its immediate neighbors. Increasing `depth` to `2` also includes assets connected to those neighbors.

Connections are followed in both directions. Each returned edge retains its original direction, so you can distinguish a project’s database from the organization that contains the project.

### Parameters

| Parameter | Type | Description |
| - | - | - |
| `nodeIds` | `string[]` | IDs of the assets to start from. |
| `depth` | `number` | Number of connections to follow from each starting asset. Defaults to `1`. |

### Return value

The result contains `nodes` and `edges` arrays. Nodes appear once in the result, even when several paths lead to them. Each edge references nodes in the returned array through `fromId` and `toId`.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
for (const node of graph.nodes) {
  console.log(node.id, node.labels, node.properties);
}

for (const edge of graph.edges) {
  console.log(edge.fromId, edge.label, edge.toId);
}
```

You can use these arrays to display a graph or inspect relationships in your own code. For example, this finds the databases connected to the selected project:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
const nodesById = new Map(
  graph.nodes.map((node) => [node.id, node]),
);

for (const edge of graph.edges) {
  if (
    edge.fromId === "project_123" &&
    edge.label === "HAS_DATABASE"
  ) {
    const database = nodesById.get(edge.toId);
    console.log(database?.properties.host);
  }
}
```

## Query the map

Use `antigen.assetMap.query()` when you want to select assets by their properties, follow particular relationships, or compute values such as resource counts.

Build the query with [Neo4j’s Cypher Builder](https://neo4j.com/docs/cypher-builder/current/):

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install @neo4j/cypher-builder
```

This example finds Supabase projects in a region and returns their IDs and names:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Cypher from "@neo4j/cypher-builder";

const project = new Cypher.Node();

const query = new Cypher.Match(
  new Cypher.Pattern(project, {
    labels: ["SupabaseProject"],
  }),
)
  .where(project, {
    region: new Cypher.Param("us-east-1"),
  })
  .return(
    [project.property("id"), "id"],
    [project.property("name"), "name"],
  );

const projects = await antigen.assetMap.query(query);
```

`Cypher.Param` supplies the region as a query parameter. The aliases in `.return()` name the fields in each result:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
// Example result
[
  { id: "project_123", name: "production" },
  { id: "project_456", name: "staging" },
]
```

You can use those IDs to explore the matching projects:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
const graph = await antigen.assetMap.get({
  nodeIds: projects.map((project) => String(project.id)),
  depth: 1,
});
```

### Parameters

| Parameter | Description |
| - | - |
| `query` | A query object constructed with `@neo4j/cypher-builder`. The SDK builds and executes the query with its parameters. |

### Return value

Returns an array of rows. Each row contains the fields selected by the query. A query with no matches returns an empty array.

Queries can select properties, nodes, relationships, paths, and aggregate values. Returned nodes and edges use the same representation as `get()`. Paths contain `nodes` and `edges` arrays.

The builder provides TypeScript types for constructing queries. Label names, property names, and result fields depend on the graph schema.

## Node and edge fields

### Node

| Field | Type | Description |
| - | - | - |
| `id` | `string` | Identifier used to retrieve the asset and resolve edge endpoints. |
| `labels` | `string[]` | Labels describing the asset. A node can have multiple labels. |
| `properties` | Object | Asset details supplied by its integration. |

### Edge

| Field | Type | Description |
| - | - | - |
| `id` | `string` | Identifier for the relationship. |
| `fromId` | `string` | Source node’s ID. |
| `toId` | `string` | Destination node’s ID. |
| `label` | `string` | Relationship type, such as `RESOURCE` or `HAS_DATABASE`. |
| `properties` | Object | Additional details about the relationship. |

## Access

Both methods provide read-only access to your organization’s map. Queries that create, update, or delete graph data are rejected.

You can call these methods from scripts, applications, or external agent environments using [API key authentication](/docs/sdk/authentication). Connecting infrastructure is covered in [Connecting infrastructure](/docs/asset-map/connecting-infrastructure).
