# Exchange filtering

You can choose to receive announcements from specific exchanges only, rather than receiving everything.

## How filtering works

Filtering is applied at two levels:

### 1. Key-level restriction (set by administrator)

When your API key is created, the administrator can restrict it to specific exchanges. For example, a key may be limited to `binance,upbit` only.

You can check your key's allowed exchanges in the [welcome message](https://cryptolistingws.gitbook.io/docs/websocket-api#welcome-message) you receive upon connection:

```json
{
  "type": "welcome",
  "allowedCex": "binance,upbit",
  ...
}
```

A value of `"*"` means your key has access to all exchanges.

### 2. Client-side preference (set by you)

When connecting, you can further narrow your subscription using the `cex` query parameter:

```
wss://cryptolisting.ws?cex=binance
```

Multiple exchanges:

```
wss://cryptolisting.ws?cex=binance,upbit
```

All exchanges (default):

```
wss://cryptolisting.ws
```

### Effective filter

The effective filter is the **intersection** of your key's allowed exchanges and your client-side preference:

| Key allows      | You request     | You receive             |
| --------------- | --------------- | ----------------------- |
| `*` (all)       | `binance`       | `binance`               |
| `*` (all)       | `binance,upbit` | `binance,upbit`         |
| `*` (all)       | *(nothing)*     | All exchanges           |
| `binance,upbit` | `binance`       | `binance`               |
| `binance,upbit` | `upbit`         | `upbit`                 |
| `binance,upbit` | *(nothing)*     | `binance,upbit`         |
| `binance`       | `upbit`         | *(nothing -- no match)* |

{% hint style="warning" %}
If your key restricts you to `binance` and you request `upbit`, you will connect successfully but receive **no announcements** (heartbeats are still sent).
{% endhint %}

## Heartbeats are always delivered

Heartbeat messages are always sent regardless of your exchange filter. They are not tied to any specific exchange.
