Filter Configuration

Learn how to use our WebSocket filters to get the data you need.

Applying Filters to WebSocket Data Streams

To customize the data streams received from a WebSocket connection, apply filters by sending a configuration message after establishing the connection. Each data stream type (such as trades, transfers, or oracles) is represented as an array within the filters property of the configuration message. This structure allows you to apply multiple filters to any data stream for more precise data selection.

How to Send a Configuration Message

  1. Construct the Configuration Message:
    • Each data stream type is an array of objects within the filters property.
    • Specify filter criteria within the corresponding set of objects array.
    • If an array is empty, it means you will receive all data for that type.
    • If corresponding array property is missing - you will not receive any related massages.
  2. Example Configuration Message:
    {
        "type": "configure",
        "filters": {
            "trades": [
                {
                    "programId": "YourProgramIdHere",
                    "marketId": "YourMarketIdHere"
                }
            ],
            "transfers": [], // This will receive all transfer events
            "oraclePrices": [] // This will receive all oracle events
        }
    }
    

Example Multi-Filtering Configuration Message

{
    "type": "configure",
    "filters": {
        "trades": [
            {
                "programId": "YourProgramIdHere",
                "marketId": "YourMarketIdHere"
            },
            {
                "tokenMintAddress": "So11111111111111111111111111111111111111112"
            }
        ],
        "transfers": [], // This will receive all transfer events
        "oraclePrices": [] // This will receive all oracle events
    }
}

Important Notes:

  • Empty Objects: If the array for a data stream type is empty, you will receive all data for that type. For example, an empty transfers array means you will get all transfer events.
  • Combination of Filters: Filters can be combined in any way to tailor the data you need, ensuring you only receive relevant data. By following these instructions, you can effectively apply filters to your WebSocket data streams and manage the data you receive according to your needs.
  • Multiple Filters:You can apply multiple filters simultaneously within the same configuration message. This will allow you to get trades, transfers or prices for multiple mints, programs or markets with the same WebSocket connection. This allows you to receive data streams that match all specified conditions, helping you narrow down the exact events you're interested in tracking.