---
title: "Find where a package is used"
sidebarTitle: "Find a package"
description: "Search the software inventory by Package URL, see what pulls a component in at any depth, and walk the asset graph around an affected asset."
keywords: ["software inventory", "components", "package URL", "purl", "dependents", "dependency graph", "asset graph", "SBOM"]
---

When an advisory names a package, the first question is where you have it.
Every scan and every [imported bill of materials](/how-to/import-and-export-sboms)
writes to one software inventory, and you can search it across every asset at
once.

Everything on this page is a read and needs `assets:read`, which every role
holds and which can be granted to an API key.

## Search by Package URL

In the dashboard, open a finding and, under **Where else**, follow the link to
every asset with that package. It opens the **Where is this package?** page
(`/components` on your workspace's address) with the Package URL filled in.
You can also enter a Package URL there yourself. Each matching installation is
listed with the asset it is on and whether it is a direct or a transitive
dependency.

Over the API:

```bash
curl -s "https://app.trustivan.com/api/v1/components?purl=pkg:npm/lodash@4.17.21" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  | jq '.components[] | {id, asset_id, name, version, direct, location_path}'
```

Whether you include a version changes the question:

| `purl` | Matches | Use it for |
|---|---|---|
| `pkg:npm/lodash@4.17.21` | That exact release | "Who is on the vulnerable version?" |
| `pkg:npm/lodash` | Every installation, whatever its version | Planning an upgrade |

Narrow the search with these parameters:

| Parameter | Effect |
|---|---|
| `asset_id` | One asset only |
| `ecosystem` | A Package URL ecosystem such as `npm`, `maven`, `pypi` or `deb` |
| `direct` | `true` returns only direct dependencies |
| `limit`, `cursor` | [Cursor pagination](/api-reference/pagination) |

Each component carries `purl`, `ecosystem`, `name`, `version`, `direct`,
`licenses`, and `first_seen_at` and `last_seen_at`. Two fields tell
installations of the same package apart: `location_path`, where it is
installed, and `layer`, the container image layer it is in. The same package
vendored in two places is two components, because each is remediated
separately.

## See what pulls a component in

A vulnerable package is rarely something you depend on directly. Reading one
component returns it with its immediate dependents:

```bash
curl -s "https://app.trustivan.com/api/v1/components/$COMPONENT_ID" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  | jq '{component: .component.purl, dependents: [.dependents[].purl]}'
```

That is one hop. To follow the chain up to what you actually ship, ask for the
transitive dependents:

```bash
curl -s "https://app.trustivan.com/api/v1/components/$COMPONENT_ID/dependents?depth=5" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

The response carries `dependents`, `total`, the `depth` that was walked and
`max_depth`, the deepest this service goes (10). Each dependent carries its
own `depth` (1 is a direct dependent) and is reported once, at its shortest
distance, so "you require this directly" and "something
several levels down does" stay distinguishable.

A `depth` above the maximum is clamped, not refused. A `depth` below 1, or one
that is not an integer, is `400`.

## Read one asset's full inventory

```bash
curl -s "https://app.trustivan.com/api/v1/assets/$ASSET_ID/components?direct=true" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

The response carries a page of `components` and the asset's `edges`. The
components are paginated; the edges are not. A page of edges would be a
subgraph with arbitrary boundaries, and a dependency chain reconstructed from
it would look complete when it was not.

An asset that does not exist, or is not yours, is `404`. You never get `200`
with an empty inventory for an asset you cannot see.

## Walk the asset graph

Components answer "which package". The asset graph answers "which things":
how one asset relates to others in your estate. A relationship reads
*parent relationship child*, and the relationship is one of `contains`, `runs`,
`builds`, `describes` or `deployed_to`.

For the assets directly next to one:

```bash
curl -s "https://app.trustivan.com/api/v1/assets/$ASSET_ID/relationships" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY" \
  | jq '{parents: [.parents[].relationship], children: [.children[].relationship]}'
```

For more than one hop, name a direction:

```bash
curl -s "https://app.trustivan.com/api/v1/assets/$ASSET_ID/graph?direction=up&depth=3" \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

| `direction` | Walks | Answers |
|---|---|---|
| `up` | Child to parent | "What ultimately runs this?" |
| `down` | Parent to child | "What does this contain?" |

`direction` is required and has no default, because the two answer different
questions. `depth` defaults to 2 and is clamped to the service maximum of 6.
The response reports the `depth` actually walked, so you can tell a graph that
ended from a walk that was cut short, and lists each node once at its
shallowest arrival.

<Note>
  The graph contains only relationships that have been recorded for your
  estate. An asset with none returns empty `parents` and `children`; that is a
  statement about what has been recorded, not proof the asset runs nowhere.
</Note>

## When the answer is 501

A deployment that does not store a software inventory, or an asset graph,
answers `501` on these endpoints instead of returning an empty result. An
empty list always means "nothing matched", never "not available here".

## See also

- [Import and export SBOMs](/how-to/import-and-export-sboms)
- [Export a licence compliance inventory](/how-to/export-license-inventory)
- [Assets and scans](/concepts/assets-and-scans)
