---
title: clients
sidebarTitle: clients
---

# `prefect.events.clients`

## Functions

### `http_to_ws` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L77" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
http_to_ws(url: str) -> str
```

### `events_in_socket_from_api_url` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L81" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
events_in_socket_from_api_url(url: str) -> str
```

### `events_out_socket_from_api_url` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L85" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
events_out_socket_from_api_url(url: str) -> str
```

### `get_events_client` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L89" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
get_events_client(reconnection_attempts: int = 10, checkpoint_every: int = 700) -> 'EventsClient'
```

### `get_events_subscriber` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
get_events_subscriber(filter: Optional['EventFilter'] = None, reconnection_attempts: int = 10) -> 'PrefectEventSubscriber'
```

## Classes

### `EventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L150" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


The abstract interface for all Prefect Events clients


**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

#### `emit` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L157" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
emit(self, event: Event) -> None
```

Emit a single event


### `NullEventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L188" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Prefect Events client implementation that does nothing


**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

#### `emit` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L157" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
emit(self, event: Event) -> None
```

Emit a single event


### `AssertingEventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L195" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Prefect Events client that records all events sent to it for inspection during
tests.


**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

#### `emit` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L157" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
emit(self, event: Event) -> None
```

Emit a single event


#### `pop_events` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L219" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
pop_events(self) -> List[Event]
```

#### `reset` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L213" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
reset(cls) -> None
```

Reset all captured instances and their events. For use between
tests


### `PrefectEventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L247" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Prefect Events client that streams events to a Prefect server


**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

#### `emit` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L157" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
emit(self, event: Event) -> None
```

Emit a single event


### `AssertingPassthroughEventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L422" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Prefect Events client that BOTH records all events sent to it for inspection
during tests AND sends them to a Prefect server.


**Methods:**

#### `pop_events` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L445" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
pop_events(self) -> list[Event]
```

#### `reset` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L441" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
reset(cls) -> None
```

### `PrefectCloudEventsClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L463" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


A Prefect Events client that streams events to a Prefect Cloud Workspace


### `PrefectEventSubscriber` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L498" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Subscribes to a Prefect event stream, yielding events as they occur.

Example:

    from prefect.events.clients import PrefectEventSubscriber
    from prefect.events.filters import EventFilter, EventNameFilter

    filter = EventFilter(event=EventNameFilter(prefix=["prefect.flow-run."]))

    async with PrefectEventSubscriber(filter=filter) as subscriber:
        async for event in subscriber:
            print(event.occurred, event.resource.id, event.event)


**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L560" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

### `PrefectCloudEventSubscriber` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L686" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

**Methods:**

#### `client_name` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L560" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
client_name(self) -> str
```

### `PrefectCloudAccountEventSubscriber` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/events/clients.py#L712" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
