chainlink WebSocket
subscription.
The current default delivers both TWAP windows. Select spot or one TWAP window
explicitly when that is all your application needs.
Choose spot
Addprice_source: "spot":
Choose TWAP
Usetwap_windows to select a lookback:
For example, subscribe to both windows for BTC/USD and ETH/USD:
30 and 60 are lookback windows, not update rates. Read
twap_window_seconds on each event instead of inferring the window from event
timing.
Follow the current default
Omit both selectors to follow the current default:price_source: "follow_main" and
twap_windows: null. The current default sends both the 30-second and
60-second TWAP streams.
Selection rules
price_sourceaccepts"spot".twap_windowsaccepts[30],[60], or[30, 60].- Do not combine
price_source: "spot"withtwap_windows. - Omit
feedsto receive every available pair. - Spot and TWAP subscriptions begin with the next update. They do not include a snapshot, history, or replay.
Identify each event
Every event keeps the existingprice_feed shape and adds two fields that
identify the price type:
is_twap is false and twap_window_seconds is null. For
TWAP events, is_twap is true and twap_window_seconds is 30 or 60.
When both windows are selected, the two events for one feed are separate price
observations. Key application state by feed and twap_window_seconds, and
include timestamp when deduplicating delivery.
Existing clients can keep their WebSocket URL, API key, subscription type, and
existing JSON fields unchanged. Add a selector only when the application needs
spot or one exact TWAP window.
