# Count the edges of each edge type (/build/count-edges-by-type)

Read in one request how many edges of each edge type a credential can read, to show which edge types an instance uses.



An app that shows how items link, such as a filter that offers only the [edge types](/build/edges#edge-types) in use, needs to know how many edges each one has. **One request counts them all,** so the app doesn't page through every edge. **You need** a credential that reads at least one type.

## Ask for the counts [#ask-for-the-counts]

[List edge types](/reference/api/edge-types/listEdgeTypes) with `include=counts`. In the TypeScript example, `marfa` is a [TypeScript SDK client](/reference/typescript-sdk#create-a-client).



**CLI**

```bash  
marfa edge-types list --counts --json
```

**HTTP**

```http
GET /edge-types?include=counts
Authorization: Bearer <key>
```

**TypeScript**

```ts
const { data } = await marfa.GET("/edge-types", {
  params: { query: { include: "counts" } },
});
```

Each edge type the credential can read gains a `count`. The answer is the whole list, with no further page.

From the next Marfa release after v0.0.122, `marfa edge-types list --counts` also prints a `count` column without `--json`; in v0.0.122, only `--json` shows the count.

## What a count takes in [#what-a-count-takes-in]

**A count is the number of edges that [List edges](/reference/api/edges/listEdges) answers the same credential for that edge type,** paged to its end with no other filter. So a count:

* **Includes the edges of items in the bin,** as the listing does.
* **Leaves out an edge whose from item the credential can't read.**

Some edge types get no `count`:

| When | The answer |
| - | - |
| The credential's edge map doesn't let it read the edge type | The edge type, without a `count` |
| The credential reaches no type | The list, with no `count` on any edge type |
| The request leaves out `include=counts` | The list, with no `count` on any edge type |
| `include` names anything else | `400 validation_error` |

A plugin's connector key that reaches a type only through its [mapping](/use/map-a-connector) gets counts.

## Read the counts in the overview [#read-the-counts-in-the-overview]

[Get an overview](/reference/api/instance/getOverview) gives each edge type it lists the same `count`, and its `reverse_name` when it has one. It lists only the edge types the credential can read, so every one has a `count`.

`marfa overview` prints both for each edge type. An agent reads them from `marfa_overview` called with no arguments, and can [name an edge by its reverse name](/reference/mcp-item-writes#edges-saved-with-an-item) when it saves an item.

The rules are in the contract, under [Edge types](https://github.com/withmarfa/marfa/blob/main/conformance/spec/edges.md#edge-types) in the edges chapter and [What a credential can reach](https://github.com/withmarfa/marfa/blob/main/conformance/spec/instance.md#what-a-credential-can-reach) in the instance chapter.
