Skip to main content
Websockets provide a persistent, bidirectional connection between your application and Allium, enabling real-time data delivery with lower latency than traditional HTTP requests. Allium offers two websocket capabilities:
  1. APIs over Websockets - Call any Allium API through a persistent websocket connection for faster response times
  2. Data Streams over Websockets - Subscribe to real-time blockchain data streams (wraps Kafka topics)
If you need delivery guarantees and at-least-once semantics, we recommend using Kafka or Pub/Sub directly. Websockets are best for real-time monitoring where occasional message loss is acceptable.

APIs over Websockets

APIs over websockets allow you to make API requests through a persistent connection, reducing latency by eliminating the connection overhead of individual HTTP requests.

Connection

Connect to the websocket API endpoint with your API key:

Request Format

Send requests as JSON messages with the following structure:
Request Fields:
  • method (string, required): HTTP method - GET, POST, PUT, PATCH, or DELETE
  • id (string, required): Unique identifier for tracking the request/response
  • path (string, required): API endpoint path (e.g., /api/v1/developer/assets)
  • body (object, optional): Request parameters
    • For GET requests: URL query parameters sent as key-value pairs in body
    • For POST/PUT/PATCH/DELETE: Body parameters sent as key-value pairs in body

Response Format

Responses are returned as JSON messages:
Response Fields:
  • id (string): Matches the request ID
  • status (string): Either "success" or "error"
  • data (object): Response data or error message

Example: POST Request with Body Parameters

Example: GET Request with Query Parameters

Concurrency & Rate Limits

  • Maximum 1,000 concurrent requests in flight per connection
  • However even with the above your account rate limits still apply, so you might not be able to reach 1,000 concurrent requests in flight per connection.
  • If you try to exceed this limit, you’ll receive an error response:

Benefits

  • Lower latency: No connection overhead for each request
  • Request/response matching: Use unique IDs to track async responses

Data Streams over Websockets

Stream real-time blockchain data directly to your application. All Kafka topics are available via websockets for easier integration.

Connection

Connect to a data stream by specifying a topic:

Available Topics

All Kafka topics are available. Use the format: {blockchain}.{data_type} Examples:
  • ethereum.blocks
  • ethereum.transactions
  • ethereum.logs
  • base.dex_trades
  • solana.transactions
  • hyperliquid.fills
  • bitcoin.blocks
See the Kafka documentation for the complete list of available topics and schemas.

Starting the Stream

After connecting, send a start message to begin receiving data:

Stopping the Stream

You can pause the stream without disconnecting by sending a stop message:
This is useful when you need to temporarily pause data delivery, update filters, or reduce load without closing the websocket connection.

Filtering Data (Optional)

You can filter the stream to only receive messages matching specific criteria. Send a filter with the setFilter action before starting the stream:
The data field contains the filter definition. Filters support comparison operators (=, !=, >, >=, <, <=), the in operator for arrays, the exists operator, and compound AND/OR logic. Example with compound filter:
See the Filter Syntax documentation for complete details on all operators, nested conditions, and real-world examples.

Receiving Messages

Messages are delivered as JSON:

Complete Example: Streaming Ethereum Blocks

Connection Management

Compression

Websocket compression is supported and automatically negotiated:

Reconnection

Implement reconnection logic for production applications:

Error Handling

Handle common websocket errors:

Authentication

Both websocket types require an API key passed in the connection headers:
  • APIs over Websockets: Requires it to be enabled on your account
  • Streams over Websockets: Requires it to be enabled and topic access
Contact account representative to enable websocket features on your account.

Next Steps

Filter Syntax

Learn how to filter streams with complex conditions

Kafka Streams

Production-grade streaming with delivery guarantees

API Reference

Explore available API endpoints