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

***

# Function: getEvents()

> **getEvents**(`directory`): (`options`?) => `Promise`<`Event`\[]>

Defined in: events.ts:66

Returns all events from EventCatalog.

You can optionally specify if you want to get the latest version of the events.

## 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                                                    |
| ----------------------- | ------------------------------------------------------- |
| `options`?              | { `attachSchema`: `boolean`; `latestOnly`: `boolean`; } |
| `options.attachSchema`? | `boolean`                                               |
| `options.latestOnly`?   | `boolean`                                               |

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

`Promise`<`Event`\[]>

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

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

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

// Gets all events (and versions) from the catalog
const events = await getEvents();

// Gets all events (only latest version) from the catalog
const events = await getEvents({ latestOnly: true });

// Get all events with the schema attached
const events = await getEvents({ attachSchema: true });
```
