Skip to main content

Test a Filter – Streams REST API

Updated on
Nov 11, 2026

Overview​

Tests your filter function with data from a specific block (or epoch for Validator Activity) before deploying it to a stream. This allows you to validate your filter logic and see the transformed output without affecting any live streams.

Key use cases:

  • Validate filter function syntax and logic
  • Preview transformed data output
  • Debug filter functions before deployment
  • Test filters against historical block data

Endpoint​

Send a POST request to test a filter function.

POST https://api.quicknode.com/streams/rest/v1/streams/test_filter

Request Parameters​

ParameterTypeRequiredDescription
networkstringYesBlockchain network (see Supported Chains)
datasetstringYesDataset type (see Data Sources)
filter_functionstringYesBase64-encoded JavaScript filter function
blockstringYesBlock number to test against. For validator_activity on ethereum-mainnet, supply an epoch number as a string, such as 487151.

For Ethereum Mainnet Validator Activity, use network: "ethereum-mainnet", dataset: "validator_activity", and block: "487151". The field remains named block, but selects an epoch. The filter receives stream.data as an array of epoch objects. Use the validator watchlist example to keep preview output small.

Example Request​

curl -X POST "https://api.quicknode.com/streams/rest/v1/streams/test_filter" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"network": "ethereum-mainnet",
"dataset": "block",
"filter_function": "ZnVuY3Rpb24gbWFpbihkYXRhKSB7CiAgcmV0dXJuIHsKICAgIGhhc2g6IGRhdGEuc3RyZWFtRGF0YS5oYXNoLAogICAgbnVtYmVyOiBwYXJzZUludChkYXRhLnN0cmVhbURhdGEubnVtYmVyLCAxNikKICB9Owp9",
"block": "18000000"
}'

Response​

On success, the API returns the result of applying your filter function to the specified block's data.

{
"logs": [],
"result": "{...}"
}

Response Fields​

FieldTypeDescription
logsarrayAny console logs output by your filter function
resultstringThe result of the filter test
tip

If your filter function has errors, the response will contain error details to help you debug the issue.