Any language with a websocket client can directly subscribe to the Stream API and receive updates. The developer will need the following to subscribe:
- Base Endpoint:
- Mainnet: wss://feeds.element.market/websocket
- Testnet: wss://feeds-test.element.market/websocket - API Key
- Collection slug they’d like to subscribe to
- Can use * to subscribe to all - Event types to subscribe to
- item_listed
- item_sold
- item_received_offer
- collection_offer
- item_cancel
- item_bid_cancel
- item_transferred
- item_metadata_updated - Chain types to subscribe to
- ethereum
- polygon
- bsc
- avalanche
- arbitrum
- zksync
- linea
- starknet
- opbnb
- base
- scroll
- manta_pacific
- optimism
- mantle
- zkfair
- blast
- merlin
- mode
- cyber
- bob
- lightlink - Market types to subscribe to
- element
- opensea
- blur
Step 1. Connecting
Construct your full connection string as: {base_endpoint}?token={api_key} For example: wss://feeds-test.element.market/websocket?token=<API_KEY> And set up your client to connect to this endpoint. You should ping the Server every 30 seconds with a heartbeat message that should look as follows:
{"topic":"ping"}
server response with
{"topic":"pong"}
Step 2: Subscribing to a collection
Figure out the slug of the collection you’d like to join and the event type you’d like to subscribe to, the chain where the event is located, and the market it belongs to. Send the following message to subscribe to a collection:
{"method": "SUBSCRIBE","topic":"collection:*","events":[],"payload":{"chains":["ethereum","bsc"],"markets":["element"]}}
Subscription is based on topic, sending subscription information of the same topic will overwrite the previous subscription
Step 3: Unsubscribing from a collection
To unsubscribe, you’ll need to just change the method field to UNSUBSCRIBE, and make sure the topic is same as the SUBSCRIBE.
{"method": "UNSUBSCRIBE","topic":"collection:*","events":[],"payload":{"chains":["ethereum","bsc"],"markets":["element"]}}