Complete EVM API Specification
View the full OpenAPI documentation with all available fields, filters, and
detailed schemas →
Base URL
All Portal requests are made to:{network} with your target blockchain (e.g., ethereum-mainnet, polygon-mainnet, arbitrum-one).
Core Endpoints
POST /stream
Stream blockchain data with filters. Includes unfinalized blocks.
POST /finalized-stream
Stream only finalized blocks. Use for production pipelines requiring
certainty.
GET /metadata
Get dataset information: block range, finality rules, and network details.
GET /timestamps/{timestamp}/block
Resolve a Unix timestamp to the first block at or after it.
Installation
Quick Start Examples
Available Fields
Block Fields
Select which block header fields to retrieve:Transaction Fields
Select transaction data fields:Log Fields
Select event log fields:Trace Fields
Select call trace fields. The selectors are prefixed by trace kind (call*, create*, suicide*, reward*); there are no bare from/to/value selectors:
The response nests these fields, and
transactionHash is not a trace field.- Requested
call*/create*selectors come back grouped underactionandresultsub-objects, not flat. For examplecallFrom/callTo/callValueare returned asaction.{from,to,value}, andcallResultGasUsedasresult.gasUsed. Numeric values such asaction.valueare hex wei (e.g."0x0"). transactionHashis not a validfields.trace.*selector. To get a trace’s transaction hash, join the parent transaction: set"transaction": truein the traces filter and requestfields.transaction.hash.- The
@subsquid/portal-clienttyped client flattens theaction/resultnesting back to thecallFrom/callResultGasUsedfield names; the nesting above describes the raw HTTP (curl) response.
State Diff Fields
Select state change fields:Filtering Options
Log Filters
Filter logs by contract address and event topics:- Multiple addresses in one object = OR
- Multiple topics in one object = AND
- Multiple filter objects = OR
Transaction Filters
Filter transactions by sender, recipient, or function signature:Trace Filters
Filter traces by type, caller, or callee:State Diff Filters
Filter state changes by contract address:Network Selection
Specify the EVM network when creating the data source:View All Networks
See complete list of 100+ supported EVM networks
Query Patterns
Pattern 1: Range Query
Query a specific block range:Pattern 2: Batch Processing
Process large ranges in batches:Pattern 3: Multi-Contract Query
Query multiple contracts simultaneously:Performance Optimization
1. Request Only Needed Fields
2. Use Specific Filters
3. Optimal Batch Sizes
4. Parallel Queries
Resolve a timestamp to a block
GET /datasets/{dataset}/timestamps/{timestamp}/block returns the number of the first block whose timestamp is greater than or equal to the given Unix timestamp (in seconds). Use it to turn a wall-clock time into a fromBlock for a stream query.
x-sqd-data-source response header reports which one served the result (network or real_time). The endpoint returns 404 if no block at or after the timestamp exists yet.
Stream continuation
A single/stream response is a batch, not the complete range. The server may close the connection at any point: when a worker’s range ends, when a connection is recycled, or at the current dataset head. Clients that treat one HTTP response as the whole query will silently drop blocks.
To stream a range to completion, loop:
- Read the last block’s
header.number, issue the next request withfromBlock = lastNumber + 1. - Keep
toBlock,fields, and filters identical across retries. - A
204 No Contentresponse means the range is above the dataset head. For historical queries, you’re done; for open-ended queries, wait and retry.
Handling reorgs near the chain head
When a request starts at or near the chain tip, the block you asked for may no longer be on the canonical chain by the time Portal processes the query. To detect this, passparentBlockHash with each request (the hash of the block immediately before fromBlock):
parentBlockHash, Portal returns HTTP 409 with the base_block_mismatch error and a list of blocks that are on the current canonical chain:
previousBlocks sits at the top level, beside error. It is ordered ascending (the last entry is the most recent block) and always contains at least the parent of the requested fromBlock.
Client recovery:
- Find a block in your local state whose
(number, hash)matches one ofpreviousBlocks. - Roll back your pipeline to that block.
- Resume the stream with
fromBlock = matched.number + 1andparentBlockHash = matched.hash. - If nothing in
previousBlocksmatches your records, the divergence is deeper than the returned slice: open a new stream with an earlierfromBlock(again passingparentBlockHash) and repeat the search.
/finalized-stream (instead of /stream) when you don’t need real-time data: finalized history does not reorganize, so there are no new forks to handle. A 409 can still occur there when the parentBlockHash you pass is stale, for example carried over from an orphaned unfinalized block; recover the same way.
Error Handling
Every Portal error response, on any endpoint, is a JSON envelope with a machine-readabletype and code:
error.type, and match on error.code when you handle one specific case. error.message is human-readable prose that can change at any time; never parse or match on it.
A
204 No Content response is not an error: the requested range simply has no blocks yet (see Stream continuation).
The full contract, including every error.code and its HTTP status, is in Portal error handling.
Common Use Cases
Use Case 1: Event Monitoring
Monitor specific smart contract events:Use Case 2: Transaction Tracking
Track transactions to/from specific addresses:Use Case 3: Analytics Pipeline
Build analytics on blockchain data:Request Structure Reference
Every Portal request follows this structure:Response Format
Portal returns newline-delimited JSON (NDJSON), with one block per line:Common Patterns
Batch Processing
Batch Processing
Process large block ranges by splitting into manageable chunks:
Real-time Streaming
Real-time Streaming
Stream new blocks as they arrive using /finalized-stream:
Error Handling
Error Handling
Handle rate limits and network errors gracefully:
Complete API Specification
For the complete OpenAPI specification with all available fields, options, and detailed schemas:Full EVM API Specification
View complete OpenAPI documentation with all endpoints, fields, and options →
Next Steps
View Examples
Explore practical Portal examples for common use cases
Supported Networks
See complete list of 100+ supported EVM networks
Quickstart Guide
Make your first Portal request in 5 minutes