> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uniblock.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Hydromancer

> Connect to Hydromancer market data streams through Uniblock WebSockets.

Hydromancer WebSockets provide high-performance, real-time data streaming for
decentralized exchanges and DeFi protocols. By integrating Hydromancer through
Uniblock, you can access low-latency market data and transaction events via a
unified interface.

## Endpoint

To connect to Hydromancer WebSockets through Uniblock, use the following base
URL:

```plaintext theme={null}
wss://websocket.uniblock.dev/hydromancer
```

## Authentication

Uniblock supports two ways to authenticate your Hydromancer WebSocket
connection and validation requests:

1. URL query parameter: Append `apiKey=YOUR_API_KEY` to the connection string.
2. Header: Include `x-api-key: YOUR_API_KEY` in your request headers.

## Parameters

| Parameter              | Required | Description                                                        |
| ---------------------- | -------- | ------------------------------------------------------------------ |
| `chainId`              | Yes      | The blockchain network ID. Currently, only `mainnet` is supported. |
| `apiKey` / `x-api-key` | Yes      | Your unique Uniblock API key.                                      |

## Validate connection

Before integrating, use the validation endpoint to verify your credentials. You
can pass the API key in the URL or the header.

### Option 1: Header authentication

<Note>
  Header authentication is recommended to avoid exposing your API key in URLs.
</Note>

```bash theme={null}
curl --location 'https://websocket.uniblock.dev/hydromancer/validate?chainId=mainnet' \
  --header 'x-api-key: YOUR_API_KEY'
```

### Option 2: URL authentication

```bash theme={null}
curl --location 'https://websocket.uniblock.dev/hydromancer/validate?chainId=mainnet&apiKey=YOUR_API_KEY'
```

## Supported networks

| Name             | `chainId` | Status      |
| ---------------- | --------- | ----------- |
| Ethereum Mainnet | `mainnet` | Supported   |
| Testnets         | `testnet` | Coming Soon |

## Features and subscriptions

Hydromancer supports provider-specific subscription messages after connection.
Once connected, you can send subscription messages as defined in the Hydromancer
protocol documentation.

### Common channels

* L2 Book: Real-time order book snapshots and updates.
* Trades: Individual trade executions across supported DEXs.
* Mids: Real-time mid-price updates.

## Best practices

* Security: Use the `x-api-key` header where possible to avoid exposing your key
  in server logs or browser history.
* Keep-alive: Implement a heartbeat with ping/pong every 30 to 60 seconds to
  prevent connection timeouts.
* Reconnection: Use an exponential backoff strategy for reconnections to handle
  network instability.

## Pricing

Hydromancer WebSocket data transfer is billed per 0.1 MB of data received:

* Data Transfer: `1,667 CU` per 0.1 MB

## Resources

* [Hydromancer WebSocket Documentation](https://docs.hydromancer.xyz/readme/websocket)
