You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This client provides a wrapper to connect to the real-time-data-streamingWebSocket service.
How to use it
Here is a quick example about how to connect to the service and start receiving messages (you can find more in the folder examples/):
import{RealTimeDataClient}from"../src/client";import{Message}from"../src/model";constonMessage=(message: Message): void=>{console.log(message.topic,message.type,message.payload);};constonConnect=(client: RealTimeDataClient): void=>{// Subscribe to a topicclient.subscribe({subscriptions: [{topic: "comments",type: "*",// "*"" can be used to connect to all the types of the topicfilters: `{"parentEntityID":100,"parentEntityType":"Event"}`,// empty means no filter},],});};newRealTimeDataClient({ onMessage, onConnect }).connect();
How to subscribe and unsubscribe from messages
Once the connection is stablished and you have a client: RealTimeDataClient object, you can subscribe and unsubscribe to many messages streamings using the same connection.
Subscribe
Subscribe to 'trades' messages from the topic 'activity' and to the all comments messages.
client.subscribe({subscriptions: [{topic: "activity",type: "trades",},],});client.subscribe({subscriptions: [{topic: "comments",type: "*",// "*"" can be used to connect to all the types of the topic},],});
Unsubscribe
Unsubscribe from the new trades messages of the topic 'activity'. If 'activity' has more messages types and I used '*' to connect to all of them, this will only unsubscribe from the type 'trades'.
/** * API key credentials for CLOB authentication. */exportinterfaceClobApiKeyCreds{/** API key used for authentication */key: string;/** API secret associated with the key */secret: string;/** Passphrase required for authentication */passphrase: string;}
ERC1155 token ID of conditional token being traded
bio
string
Bio of the user of the trade
conditionId
string
Id of market which is also the CTF condition ID
eventSlug
string
Slug of the event
icon
string
URL to the market icon image
name
string
Name of the user of the trade
outcome
string
Human readable outcome of the market
outcomeIndex
integer
Index of the outcome
price
float
Price of the trade
profileImage
string
URL to the user profile image
proxyWallet
string
Address of the user proxy wallet
pseudonym
string
Pseudonym of the user
side
string
Side of the trade (BUY/SELL)
size
integer
Size of the trade
slug
string
Slug of the market
timestamp
integer
Timestamp of the trade
title
string
Title of the event
transactionHash
string
Hash of the transaction
Comments
Comment
Name
Type
Description
id
string
Unique identifier of comment
body
string
Content of the comment
parentEntityType
string
Type of the parent entity (Event or Series)
parentEntityID
number
ID of the parent entity
parentCommentID
string
ID of the parent comment
userAddress
string
Address of the user
replyAddress
string
Address of the reply user
createdAt
string
Creation timestamp
updatedAt
string
Last update timestamp
Reaction
Name
Type
Description
id
string
Unique identifier of reaction
commentID
number
ID of the comment
reactionType
string
Type of the reaction
icon
string
Icon representing the reaction
userAddress
string
Address of the user
createdAt
string
Creation timestamp
RFQ
Request
Name
Type
Description
requestId
string
Unique identifier for the request
proxyAddress
string
User proxy address
market
string
Id of market which is also the CTF condition ID
token
string
ERC1155 token ID of conditional token being traded
complement
string
Complement ERC1155 token ID of conditional token being traded
state
string
Current state of the request
side
string
Indicates buy or sell side
sizeIn
number
Input size of the request
sizeOut
number
Output size of the request
price
number
Price from in/out sizes
expiry
number
Expiry timestamp (UNIX format)
Quote
Name
Type
Description
quoteId
string
Unique identifier for the quote
requestId
string
Associated request identifier
proxyAddress
string
User proxy address
token
string
ERC1155 token ID of conditional token being traded
state
string
Current state of the quote
side
string
Indicates buy or sell side
sizeIn
number
Input size of the quote
sizeOut
number
Output size of the quote
sizeOut
number
Output size of the request
condition
string
Id of market which is also the CTF condition ID
complement
string
Complement ERC1155 token ID of conditional token being traded
expiry
number
Expiry timestamp (UNIX format)
CryptoPrice
Name
Type
Description
symbol
string
Symbol of the asset
timestamp
number
Timestamp in milliseconds for the update
value
number
Value at the time of update
Filters
{"symbol":"BTCUSDT"}
{"symbol":"ETHUSDT"}
{"symbol":"XRPUSDT"}
{"symbol":"SOLUSDT"}
{"symbol":"DOGEUSDT"}
EquityPrice
Name
Type
Description
symbol
string
Symbol of the asset
timestamp
number
Timestamp in milliseconds for the update
value
number
Value at the time of update
Filters
{"symbol":"AAPL"}
{"symbol":"TSLA"}
{"symbol":"MSFT"}
{"symbol":"GOOGL"}
{"symbol":"AMZN"}
{"symbol":"META"}
{"symbol":"NVDA"}
{"symbol":"NFLX"}
{"symbol":"PLTR"}
{"symbol":"OPEN"}
{"symbol":"RKLB"}
{"symbol":"ABNB"}
Initial data dump on connection
When the connection is stablished, if a filter is used, the server will dump an initial snapshoot of recent data. This applies to both CrytoPrice and EquityPrice.
Name
Type
Description
symbol
string
Symbol of the asset
data
array
Array of price data objects, each containing timestamp and value
About
A TypeScript client to receive real time data messages