Verified Price Feeds Perfect for StarkEx integrations and applications requiring cryptographic verification of price data
Overview
If you are building on StarkEx or need a robust verification mechanism for price data, this endpoint provides real-time feeds with cryptographic signatures to ensure data integrity and provenance.
Connection
Open WebSocket Connection
Connect to our WebSocket endpoint on your preferred environment: wscat -c wss://ws.devnet.pragma.build/node/v1/data/subscribe
Subscribe to Asset Pairs
Send a subscription message to start receiving updates every 500 milliseconds.
Subscription Management
Subscribing to Pairs
{
"msg_type" : "subscribe" ,
"pairs" : [ "BTC/USD" , "ETH/USD:MARK" ]
}
The response includes all pairs you are currently subscribed to, including any previous subscriptions not mentioned in your latest request.
Unsubscribing from Pairs
{
"msg_type" : "unsubscribe" ,
"pairs" : [ "BTC/USD" ]
}
Price Types
Median price from spot markets across supported exchanges.
Format Example: BTC/USD
By default, subscriptions are for index prices. Subscribing to a pair without specifying the type will subscribe to the index price.
Median price from perpetual markets across supported exchanges.
Format Example: ETH/USD:MARK
Calculation Method:
For assets quoted in a stablecoin:
Determine the median perp price of the asset quoted in the stablecoin Determine the median spot price of the stablecoin in USD Divide the median perp price by the median spot price of the stablecoin in USD For assets quoted in USD:
Determine the median perp price of the asset quoted in USD To subscribe to a mark price, append :MARK to the pair name (e.g., ETH/USD:MARK).
{
"global_asset_id" : "0x12345" ,
"median_price" : "10000000000000001" ,
"signature" : "0x154786876ae878" ,
"signed_prices" : [
{
"oracle_asset_id" : "0x12345000000000ABCDEF" ,
"oracle_price" : "1000000000000000000" ,
"signing_key" : "0x1234567890ABCDEF" ,
"timestamp" : "1234567" ,
"signature" : "0x1234567890ABCDEF"
},
{
"oracle_asset_id" : "0x12345000000000FEDCBA" ,
"oracle_price" : "1000000000000000002" ,
"signing_key" : "0xFEDCBA0987654321" ,
"timestamp" : "1234567" ,
"signature" : "0x1234567890ABCDEF"
}
]
}
Field Reference
Field Description global_asset_idUnique identifier for the asset encoded using the pair name median_priceThe median price of the asset signatureSignature of the median price by the Pragma oracle signed_pricesArray of the prices used to compute the median price oracle_asset_idUnique identifier encoded using the pair and publisher names oracle_pricePrice provided by the oracle signing_keyKey used by the oracle to sign the price timestampTime when the price was recorded signatureSignature of the price by our publisher
All numeric values are returned as strings to preserve precision, especially for assets with very small or very large prices.
Integration Examples
We’ve created a ready-to-use example with a terminal UI for testing this endpoint:
# Clone the repository
git clone https://github.com/astraly-labs/pragma-node
# Run the example
cargo run --example starkex
Connect to the Pragma websocket endpoint and subscribe to the TIA/USD index price:
import asyncio
import websockets
import json
from websockets.exceptions import ConnectionClosedError
async def connect_and_subscribe ():
uri = "wss://ws.devnet.pragma.build/node/v1/data/subscribe"
try :
# Connect to the websocket
async with websockets.connect(uri) as websocket:
# Subscribe to TIA/USD price
subscribe_msg = {
"msg_type" : "subscribe" ,
"pairs" : [ "TIA/USD" ]
}
await websocket.send(json.dumps(subscribe_msg))
print ( "Subscribed to TIA/USD" )
# Handle incoming messages
while True :
message = await websocket.recv()
data = json.loads(message)
print ( f "Received price update: { data } " )
except ConnectionClosedError:
print ( "Connection closed unexpectedly" )
except Exception as e:
print ( f "Error: { e } " )
# Run the connection
if __name__ == "__main__" :
asyncio.run(connect_and_subscribe())
Comparison with Lightspeed
Starkex ✓ Includes cryptographic signatures ✓ Verifiable price data ✓ Individual publisher prices ✓ Ideal for StarkEx integration ⚠️ Slightly larger payload size
Lightspeed ✓ Minimal payload size ✓ Optimized for performance ✓ Lower latency ✓ Ideal for trading applications ❌ No verification metadata
Choose Starkex when data provenance and verification are required, and Lightspeed when raw performance is your primary concern.