Skip to content

Websocket api

The WebSocket API provides streaming connections to the marketplace for real-time messaging. Trading and market data endpoints are available to receive live updates from the marketplace.

The Trading API allows client to receive all order and trading related updates that are connected to the specific user account.

The Market Data API allows all clients to receive market data updates such as ticker messages or orderbook updates.

Websocket API base URL: wss://glocalflexmarket.com/api/v1/ws/ e.g.: wss://glocalflexmarket.com/api/v1/ws/trade

WebSocket API Endpoints

Endpoint URL Description Message Types
/trade Trading events receive all order and contract updates
/orderbook Orderbook events subscribe to orderbook live events
/ticker Price and flexibility events subscribe tick live events

Info

The data object of the WebSocket events uses mostly the message format described in the REST API reference. To check units or description of specific fields please consult the REST API reference for further information.

Control Messages

During the initial successful connection, the WebSocket server sends a control message to the client to confirm the connection.

control_message

{
    "type": "control",
    "status": "success",
    "data": {
        "message": "Connected to the WebSocket API"
    }
}

Trading

/trade

The trading endpoint sends order and trade updates to the client. The user sends the access token during the initial connection to authenticate the user. Based on the access token the client receives all order and trade updates that are connected to the specific user account.

Note

The user only receives updates connected to its user id.

Event Type Description
order_status_update Status of an existing order has changed
contract_status_update Status updates for the contract associated with your orders
Status name Description
awaiting_baseline_data Order is waiting for baseline data
accepted Order has been accepted
matching_active Order is active in the matching engine
filled Order has been fully filled

order_status_update

 {
    "type": "order_status_update",
    "name": str,
    "created_at": date-time, 
    "data": {
        // order object
    }
} 

contract_status_update

Status name Description
verification_initiated Contract verification started
verification_completed_success Contract verification succeeded
settlement_initiated Contract settlement started
settlement_completed_success Contract settlement succeeded
 {
    "type": "order_status_update",
    "name": str,
    "created_at": date-time, 
    "data": {
        // contract object
    }
} 

Market Data

/ticker

The ticker endpoint streams market updates of the last matched orders to all connected clients. The message contains the last price and basic information about the flexibility event. After connecting to the WebSocket endpoint the updates are streamed to the client.

Event Type Description
ticker_update Information about the last trade closed in the marketplace
expired_order_update Order that has been expired inside the orderbook

ticker_update

 {
    "type": "ticker_update",
    "created_at": date-time, 
    "data": {
        "closed_at": date-time, // "2024-05-02T12:06:45.842304Z",
        "price": float,
        "delivery_start": date-time, // "2024-05-02T13:15:00.000Z",
        "delivery_end":  date-time, //"2024-05-02T14:15:00.000Z",
        "energy": float,
        "power": float,
        "location": {
            "location_id": [str],
            "country_code": str,
            "coordinates": {
                "latitude": float,
                "longitude": float
            }            
        }
    }
}
 {
    "type": "expired_order_update",
    "created_at": date-time, 
    "data": {
        "expired_at": data-time, // "2024-05-02T12:06:45.842304Z",
        "price": float,
        "delivery_start": date-time, // "2024-05-02T13:15:00.000Z",
        "delivery_end":  date-time, //"2024-05-02T14:15:00.000Z",
        "energy": float,
        "power": float,
        "location": {
            "location_id": [str],
            "country_code": str,
            "coordinates": {
                "latitude": float,
                "longitude": float
            }             
        }
    }

/orderbook

The orderbook endpoint streams the orderbook updates to all connected clients. The message contains the current orderbook state with bids and asks sort by price and time priority. The bids are sorted by price descending and the asks are sorted by price ascending.

orderbook_update

{
    "type": "orderbook_update",
    "created_at": date-time, 
    "data": {
        "bids": {
            "100": [
                {
                    "side": str, // buy
                    "power": float,
                    "price": float,
                    "delivery_start": date-time,
                    "delivery_end": date-time,
                    "location": {
                        "location_id": [
                            str
                        ],
                        "country_code": str
                    },
                    "energy": float
                },
                {
                    "side": str, // buy
                    "power": float,
                    "price": float,
                    "delivery_start": date-time,
                    "delivery_end": date-time,
                    "location": {
                        "location_id": [
                            str
                        ],
                    },
                    "energy": float
                },
                {
                    "side": str, // buy
                    "power": float,
                    "price": float,
                    "delivery_start": date-time,
                    "delivery_end": date-time,
                    "location": {
                        "location_id": [
                            str
                        ],
                        "country_code": str
                    },
                    "energy": float
                }
            ]
        },
        "asks": {
            "11": [
                {
                    "side": str, // sell
                    "power": float,
                    "price": float,
                    "delivery_start":  date-time,
                    "delivery_end": date-time,
                    "location": {
                        "location_id": [
                            str
                        ],
                        "country_code": str
                    },
                    "energy": float
                },
                { 
                    "side": str, // sell
                    "power": float,
                    "price": float,
                    "delivery_start": date-time,
                    "delivery_end": date-time,
                    "location": {
                        "location_id": [
                            str
                        ],
                        "country_code": str
                    },
                    "energy": float
                }
            ]
        }
    }
}