# How to Query Relationships in a .lottie File
Use dotlottie-io's cross-reference query methods to find which animations use a theme, state machine, or asset.

# How to Query Relationships in a .lottie File

`dotlottie-io` exposes four query methods — available on both [`DotLottie`](/docs/tools/dotlottie-io/api/dotlottie-class) and [`DotLottieReader`](/docs/tools/dotlottie-io/api/dotlottie-reader-class) — for inspecting how content in a package references other content. `dotlottie-js` has no equivalent to these.

## Which animations use a theme?

```javascript
dotlottie.animationsUsingTheme("dark"); // → string[]
```

Returns animation IDs whose manifest entry references the given theme, via `initialTheme` or the `themes` array.

## Which animations does a state machine control?

```javascript
dotlottie.animationsUsedByStateMachine("sm-button"); // → string[]
```

Returns every unique animation ID referenced by a `PlaybackState` entry in the given state machine.

## What assets does an animation reference?

```javascript
dotlottie.assetReferences("hero"); // → { images: string[], fonts: string[], audio: string[] }
```

Returns categorized, external asset filenames referenced by the animation's Lottie JSON.

## Which animations use a given asset?

```javascript
dotlottie.animationsUsingAsset("logo.png"); // → string[]
```

The reverse lookup of `assetReferences` — useful for auditing.

## Worked example: finding unused assets before shipping

```javascript
const { DotLottie } = require("@lottiefiles/dotlottie-io");

const dl = DotLottie.fromFile("package.lottie");

const unusedImages = dl.imageFilenames().filter((filename) => dl.animationsUsingAsset(filename).length === 0);

const unusedAudio = dl.audioFilenames().filter((filename) => dl.animationsUsingAsset(filename).length === 0);

if (unusedImages.length || unusedAudio.length) {
  console.warn("Unused assets found:", { unusedImages, unusedAudio });
}
```

## A note on `DotLottieReader`

The same four methods exist on `DotLottieReader`, with different costs: `animationsUsingTheme` reads only the manifest (free), while `animationsUsedByStateMachine` and `assetReferences` each read one ZIP entry, and `animationsUsingAsset` reads every animation entry (O(n)). If you're calling `animationsUsingAsset` repeatedly, load the file with `DotLottie` instead — it's already fully parsed in memory.

## Related

- [`DotLottie` API reference](/docs/tools/dotlottie-io/api/dotlottie-class)
- [Managing Assets](/docs/tools/dotlottie-io/core-concepts/assets)
