> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.sqd.dev/feedback

```json
{
  "path": "/en/api/hyperliquid-fills/stream",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Stream Blocks

> Returns blocks matching the query. May include unfinalized blocks. Response is a JSON array of blocks containing the requested fields. Set toBlock to limit the range, or omit it to stream up to the dataset height. Supports gzip compression via Accept-Encoding and Content-Encoding headers.




## OpenAPI

````yaml /en/api/catalog/hyperliquid/openapi-fills.yaml post /stream
openapi: 3.1.0
info:
  title: SQD Portal API - Hyperliquid Fills Dataset Endpoints
  description: >-
    API endpoints for interacting with Hyperliquid fills datasets under the SQD
    Portal, specifically for the hyperliquid-mainnet dataset.
  version: 1.0.0
servers:
  - url: https://portal.sqd.dev/datasets/hyperliquid-fills
    description: SQD Portal's endpoint for Hyperliquid Mainnet
security: []
paths:
  /stream:
    post:
      summary: Stream Blocks
      description: >
        Returns blocks matching the query. May include unfinalized blocks.
        Response is a JSON array of blocks containing the requested fields. Set
        toBlock to limit the range, or omit it to stream up to the dataset
        height. Supports gzip compression via Accept-Encoding and
        Content-Encoding headers.
      requestBody:
        description: Data query to filter and retrieve blocks
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataQuery'
            examples:
              btc-fills:
                summary: Query BTC Fills
                value:
                  type: hyperliquidFills
                  fromBlock: 900000000
                  toBlock: 900000100
                  fields:
                    block:
                      number: true
                      timestamp: true
                    fill:
                      user: true
                      coin: true
                      px: true
                      sz: true
                      side: true
                      dir: true
                      fee: true
                  fills:
                    - coin:
                        - BTC
      responses:
        '200':
          description: >-
            A stream of blocks in JSON lines format, optionally gzipped. Can be
            empty if the data query has a bounded range and all blocks in the
            range have been skipped. May include X-Sqd-Finalized-Head-Number and
            X-Sqd-Finalized-Head-Hash headers, indicating the latest finalized
            block that's on the same chain as the returned blocks.
          headers:
            X-Sqd-Finalized-Head-Number:
              schema:
                type: integer
                format: int64
              description: >-
                Block number of the latest finalized block. Returned blocks can
                be above, at, or below this block number.
              required: false
            X-Sqd-Finalized-Head-Hash:
              schema:
                type: string
              description: >-
                Hash of the latest finalized block. All returned blocks are
                guaranteed to belong to the same (not necessarily final) chain
                as this block.
              required: false
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Block'
              examples:
                btc-fills-response:
                  summary: BTC fills response
                  value:
                    - header:
                        number: 900000050
                        timestamp: 1710000000000
                      fills:
                        - user: '0xabc123def456abc123def456abc123def456abc1'
                          coin: BTC
                          px: '67234.5'
                          sz: '0.1'
                          side: B
                          dir: Open Long
                          fee: '6.7234'
        '204':
          description: >-
            Indicates that the requested block range is entirely above the range
            of blocks available in the dataset. The portal may wait for up to 5s
            before returning this.
          content:
            text/plain:
              schema:
                type: string
          headers:
            X-Sqd-Finalized-Head-Number:
              schema:
                type: integer
                format: int64
              description: Block number of the latest finalized block.
              required: false
            X-Sqd-Finalized-Head-Hash:
              schema:
                type: string
              description: Hash of the latest finalized block.
              required: false
        '400':
          description: >
            Possible causes: (1) request headers or body encoding are incorrect;
            (2) the query is invalid - the response will include an explanation;
            (3) fromBlock is below the dataset's start_block (see /metadata).
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: Dataset not found
          content:
            text/plain:
              schema:
                type: string
        '409':
          description: >-
            Conflict due to a mismatched parent block hash. This will happen
            when the client requests a range starting with an orphaned block in
            the real-time setting. The response contains a list of previous
            blocks belonging to the current chain; the client should find a
            block matching one of these (by both hash and block number) in its
            records and restart the stream and its business logic from that
            block.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictResponse'
        '429':
          description: >-
            Too many requests; rate limit exceeded. May include a Retry-After
            header indicating the number of seconds to wait before retrying the
            request.
          content:
            text/plain:
              schema:
                type: string
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
        '500':
          description: Internal server error. Do not retry requests causing these.
          content:
            text/plain:
              schema:
                type: string
        '503':
          description: >-
            The server could not process the request at the moment. The client
            should retry the request later. May include a Retry-After header
            indicating the number of seconds to wait before retrying the
            request.
          content:
            text/plain:
              schema:
                type: string
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying
      x-codeSamples:
        - lang: shell
          label: Query BTC Fills
          source: >
            curl --compressed -X POST
            'https://portal.sqd.dev/datasets/hyperliquid-fills/stream' \
              -H 'Content-Type: application/json' \
              -d '{
                "type": "hyperliquidFills",
                "fromBlock": 900000000,
                "toBlock": 900000100,
                "fields": {
                  "block": {
                    "number": true,
                    "timestamp": true
                  },
                  "fill": {
                    "user": true,
                    "coin": true,
                    "px": true,
                    "sz": true,
                    "side": true,
                    "dir": true,
                    "fee": true
                  }
                },
                "fills": [{
                  "coin": ["BTC"]
                }]
              }'
        - lang: python
          label: Query BTC Fills
          source: |
            import requests

            response = requests.post(
                "https://portal.sqd.dev/datasets/hyperliquid-fills/stream",
                json={
                    "type": "hyperliquidFills",
                    "fromBlock": 900000000,
                    "toBlock": 900000100,
                    "fields": {
                        "block": {
                            "number": True,
                            "timestamp": True
                        },
                        "fill": {
                            "user": True,
                            "coin": True,
                            "px": True,
                            "sz": True,
                            "side": True,
                            "dir": True,
                            "fee": True
                        }
                    },
                    "fills": [{
                        "coin": ["BTC"]
                    }]
                }
            )
            data = response.json()
        - lang: javascript
          label: Query BTC Fills
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-fills/stream", {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({
                    "type": "hyperliquidFills",
                    "fromBlock": 900000000,
                    "toBlock": 900000100,
                    "fields": {
                        "block": {
                            "number": true,
                            "timestamp": true
                        },
                        "fill": {
                            "user": true,
                            "coin": true,
                            "px": true,
                            "sz": true,
                            "side": true,
                            "dir": true,
                            "fee": true
                        }
                    },
                    "fills": [{
                        "coin": ["BTC"]
                    }]
                })
            });

            const data = await response.json();
components:
  schemas:
    DataQuery:
      type: object
      properties:
        type:
          type: string
          enum:
            - hyperliquidFills
          default: hyperliquidFills
          description: The type of data (fixed to hyperliquidFills for this API).
        fromBlock:
          type: integer
          format: int64
          description: The block number to start fetching from (inclusive).
        toBlock:
          type: integer
          format: int64
          description: >-
            The block number to fetch up to (inclusive). Optional; if omitted,
            streams until dataset height or timeout.
        parentBlockHash:
          type: string
          description: Expected hash of the parent of the first requested block.
        includeAllBlocks:
          type: boolean
          description: If true, includes blocks with no matching data in the response.
          default: false
        fields:
          type: object
          description: Field selector for data items to retrieve.
          properties:
            block:
              type: object
              description: Field selector for block headers.
              properties:
                number:
                  type: boolean
                  description: Include the block number.
                hash:
                  type: boolean
                  description: Include the block hash.
                parentHash:
                  type: boolean
                  description: Include the parent block hash.
                timestamp:
                  type: boolean
                  description: Include the block timestamp.
              default:
                number: true
                hash: true
                parentHash: true
            fill:
              type: object
              description: Field selector for trade fills.
              properties:
                fillIndex:
                  type: boolean
                  description: Include the fill index within the block.
                user:
                  type: boolean
                  description: Include the trader wallet address.
                coin:
                  type: boolean
                  description: Include the asset symbol (e.g., BTC, ETH).
                px:
                  type: boolean
                  description: Include the fill price.
                sz:
                  type: boolean
                  description: Include the fill size.
                side:
                  type: boolean
                  description: Include the fill side (A for ask/sell, B for bid/buy).
                time:
                  type: boolean
                  description: Include the fill timestamp.
                startPosition:
                  type: boolean
                  description: Include the trader's position size before this fill.
                dir:
                  type: boolean
                  description: Include the trade direction (e.g., Open Long, Close Short).
                closedPnl:
                  type: boolean
                  description: Include the realized PnL from closing a position.
                hash:
                  type: boolean
                  description: Include the fill hash.
                oid:
                  type: boolean
                  description: Include the order ID that generated this fill.
                crossed:
                  type: boolean
                  description: Include whether this fill was a taker fill.
                fee:
                  type: boolean
                  description: Include the fee charged for this fill.
                builderFee:
                  type: boolean
                  description: Include the additional fee paid to the order builder.
                tid:
                  type: boolean
                  description: Include the trade ID.
                cloid:
                  type: boolean
                  description: Include the client order ID.
                feeToken:
                  type: boolean
                  description: Include the token used to pay the fee.
                builder:
                  type: boolean
                  description: Include the builder wallet address.
                twapId:
                  type: boolean
                  description: Include the TWAP order ID.
        fills:
          type: array
          description: >
            Fill data requests. An empty object matches all fills; an empty
            array matches no fills.
          items:
            type: object
            properties:
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              coin:
                type: array
                items:
                  type: string
                description: Asset symbols to filter by (e.g., "ETH", "BTC").
              dir:
                type: array
                items:
                  type: string
                description: >-
                  Trade directions to filter by (e.g., "Open Long", "Close
                  Short").
              cloid:
                type: array
                items:
                  type: string
                description: Client order IDs (0x-prefixed hex) to filter by.
              feeToken:
                type: array
                items:
                  type: string
                description: Fee token symbols to filter by (e.g., "USDC").
              builder:
                type: array
                items:
                  type: string
                description: >-
                  Builder wallet addresses (0x-prefixed hex, lowercase) to
                  filter by.
      required:
        - type
        - fromBlock
    Block:
      type: object
      properties:
        header:
          type: object
          description: >-
            Block header data. Fields are conditionally returned based on the
            `fields.block` parameter in the request. Only requested fields will
            be included in the response.
          properties:
            number:
              type: integer
              format: uint64
              description: Block number.
            hash:
              type: string
              description: Block hash (0x-prefixed hex).
            parentHash:
              type: string
              description: Parent block hash (0x-prefixed hex).
            timestamp:
              type: integer
              format: uint64
              description: Block timestamp in milliseconds since Unix epoch.
        fills:
          type: array
          description: >-
            Trade fill records contained in this block. Fields are conditionally
            returned based on the `fields.fill` parameter in the request.
          items:
            type: object
            properties:
              fillIndex:
                type: integer
                format: uint64
                description: Index of the fill within the block.
              user:
                type: string
                description: Trader wallet address (0x-prefixed hex, lowercase).
              coin:
                type: string
                description: Asset symbol (e.g., "ETH", "BTC").
              px:
                type: string
                description: Fill price as a decimal string (e.g., "2345.1").
              sz:
                type: string
                description: Fill size as a decimal string (e.g., "0.5").
              side:
                type: string
                enum:
                  - A
                  - B
                description: Side of the fill. "A" = ask (sell), "B" = bid (buy).
              time:
                type: integer
                format: uint64
                description: Fill timestamp in milliseconds since Unix epoch.
              startPosition:
                type: string
                description: Trader's position size before this fill, as a decimal string.
              dir:
                type: string
                description: >-
                  Trade direction (e.g., "Open Long", "Close Long", "Open
                  Short", "Close Short").
              closedPnl:
                type: string
                description: >-
                  Realized PnL from closing a position, as a decimal string.
                  Zero for position-opening fills.
              hash:
                type: string
                description: Fill hash (0x-prefixed hex).
              oid:
                type: integer
                format: uint64
                description: Order ID that generated this fill.
              crossed:
                type: boolean
                description: Whether this fill crossed the order book (was a taker fill).
              fee:
                type: string
                description: Fee charged for this fill, as a decimal string.
              builderFee:
                type: string
                description: Additional fee paid to the order builder, as a decimal string.
              tid:
                type: integer
                format: uint64
                description: Trade ID (unique identifier for the matched trade).
              cloid:
                type: string
                nullable: true
                description: Client order ID (0x-prefixed hex), if provided by the trader.
              feeToken:
                type: string
                description: Token used to pay the fee (e.g., "USDC").
              builder:
                type: string
                nullable: true
                description: >-
                  Builder wallet address (0x-prefixed hex, lowercase), if this
                  order was routed through a builder.
              twapId:
                type: integer
                nullable: true
                description: TWAP order ID, if this fill belongs to a TWAP order.
      required:
        - header
    ConflictResponse:
      type: object
      properties:
        previousBlocks:
          type: array
          items:
            type: object
            properties:
              number:
                type: integer
                format: int64
              hash:
                type: string
            required:
              - number
              - hash
      required:
        - previousBlocks

````