# eth_subscribe

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://pharos-mainnet.g.alchemy.com/v2/{apiKey}

Subscribes to specific event types and returns a subscription ID to receive asynchronous notifications via the `eth_subscription` method.

⚠️ **WARNING: WebSocket-Only Method** ⚠️

> This method REQUIRES a WebSocket connection using `wss://` protocol. It will NOT work with standard HTTP/HTTPS requests or `curl`.
> See the [WebSocket documentation](https://alchemy.com/docs/reference/subscription-api) for examples.


Reference: https://www.alchemy.com/docs/chains/pharos/pharos-api-endpoints/eth-subscribe

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Subscription Type | string | No | The type of event to subscribe to (e.g., "newHeads", "logs", "newPendingTransactions", "syncing"). |
| Options | object | No | Optional subscription parameters, such as filtering topics for `logs`. |

## Result

**Subscription ID** (string): A unique identifier for the subscription, returned as a 32-byte hex string.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_subscribe",
  "params": [
    "newHeads"
  ],
  "id": 1
}
```

### Response

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

## OpenRPC Method Specification

```yaml
name: eth_subscribe
summary: Subscribe to Ethereum events via WebSocket (WSS required)
description: |
  Subscribes to specific event types and returns a subscription ID to receive asynchronous notifications via the `eth_subscription` method.

  ⚠️ **WARNING: WebSocket-Only Method** ⚠️

  > This method REQUIRES a WebSocket connection using `wss://` protocol. It will NOT work with standard HTTP/HTTPS requests or `curl`.
  > See the [WebSocket documentation](https://alchemy.com/docs/reference/subscription-api) for examples.
x-api-explorer: false
params:
  - name: Subscription Type
    description: The type of event to subscribe to (e.g., "newHeads", "logs", "newPendingTransactions", "syncing").
    schema:
      type: string
  - name: Options
    description: Optional subscription parameters, such as filtering topics for `logs`.
    schema:
      type: object
      additionalProperties: true
result:
  name: Subscription ID
  description: A unique identifier for the subscription, returned as a 32-byte hex string.
  schema:
    title: 32 byte hex value
    type: string
    pattern: ^0x[0-9a-f]{64}$
examples:
  - name: eth_subscribe example
    params:
      - name: Subscription Type
        value: newHeads
    result:
      name: Subscription ID
      value: '0x9c7c3f3c3c63b1b89ac0c1e0b0d3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8090a1b'
```
