Copy as Markdown[View as Markdown](/docs/sdk/functions/getDiagram.md)

***

# Function: getDiagram()

> **getDiagram**(`directory`): (`id`, `version`?) => `Promise`<`Diagram`>

Defined in: diagrams.ts:34

Returns a diagram from EventCatalog.

You can optionally specify a version to get a specific version of the diagram

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter  | Type     |
| ---------- | -------- |
| `id`       | `string` |
| `version`? | `string` |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`Diagram`>

## Example[​](#example "Direct link to Example")

```
import utils from '@eventcatalog/utils';

const { getDiagram } = utils('/path/to/eventcatalog');

// Gets the latest version of the diagram
const diagram = await getDiagram('ArchitectureDiagram');

// Gets a version of the diagram
const diagram = await getDiagram('ArchitectureDiagram', '0.0.1');
```
