> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/rpc-methods/real-time-streaming/whirligig-websocket/slotsubscribe.md).

# slotSubscribe

Subscribes to slot notifications over WebSocket (slotSubscribe); takes no parameters and returns a subscription id.

## Request

{% tabs %}
{% tab title="wscat" %}

```bash
# npm install -g wscat
wscat -c "wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>" -w -1 \
  -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "slotSubscribe"
}'
```

{% endtab %}

{% tab title="Kit" %}

```typescript
import { createSolanaRpcSubscriptions } from "@solana/kit";

const rpc = createSolanaRpcSubscriptions("wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>");

const subscription = await rpc
  .slotNotifications()
  .subscribe({ abortSignal: AbortSignal.timeout(5_000) });

for await (const notification of subscription) {
  console.log(notification);
}
```

{% endtab %}

{% tab title="web3.js" %}

```typescript
import { Connection } from "@solana/web3.js";

const connection = new Connection("https://<your-endpoint>.mainnet.rpcpool.com/<your-token>", {
  commitment: "confirmed",
  wsEndpoint: "wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>",
});

const subscriptionId = connection.onSlotChange((slotInfo) => {
  console.log("Slot info:", slotInfo);
});
```

{% endtab %}

{% tab title="Rust" %}

```rust
// Cargo.toml: anyhow = "1", futures = "0.3", solana-client = "~4.4",
// tokio = { version = "1", features = ["full"] }.
// Requires Rust 1.98.1 or newer (solana-client 4.4).
use anyhow::Result;
use futures::StreamExt;
use solana_client::nonblocking::pubsub_client::PubsubClient;

#[tokio::main]
async fn main() -> Result<()> {
    let pubsub_client = PubsubClient::new("wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>").await?;

    let (mut notifications, unsubscribe) = pubsub_client.slot_subscribe().await?;

    while let Some(notification) = notifications.next().await {
        println!("{:?}", notification);
    }

    unsubscribe().await;

    Ok(())
}
```

{% endtab %}
{% endtabs %}

In Rust, [`PubsubClient::slot_subscribe`](https://docs.rs/solana-pubsub-client/latest/solana_pubsub_client/nonblocking/pubsub_client/struct.PubsubClient.html#method.slot_subscribe) in the `solana-pubsub-client` crate sends this request.

## Parameters

**None**

## Response

```json
{
  "jsonrpc": "2.0",
  "result": 0,
  "id": 1
}
```

## Result

Subscription id. Pass this to [slotUnsubscribe](/solana/rpc-methods/real-time-streaming/whirligig-websocket/slotunsubscribe.md).

***

*Adapted from the* [*Solana `slotSubscribe` reference*](https://solana.com/docs/rpc/websocket/slotsubscribe)*, maintained by the Solana Foundation.*

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
