openapi: 3.1.0
info:
  title: SQD Portal API - Hyperliquid Replica Commands Dataset Endpoints
  description: >-
    API endpoints for interacting with Hyperliquid replica commands datasets
    under the SQD Portal. Captures all L1 blockchain actions (orders, cancels,
    transfers, etc.) with their exchange responses.
  version: 1.0.0
servers:
  - url: https://portal.sqd.dev/datasets/hyperliquid-replica-cmds
    description: SQD Portal's endpoint for Hyperliquid Replica Commands (Mainnet)
paths:
  /metadata:
    get:
      summary: Dataset Metadata
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/metadata
        metadata:
          description: >-
            Get Hyperliquid replica commands dataset metadata from the SQD
            Portal API.
      x-codeSamples:
        - lang: shell
          label: Get Replica Commands Metadata
          source: >
            curl --compressed
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/metadata'
        - lang: python
          label: Get Replica Commands Metadata
          source: |
            import requests

            response = requests.get(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/metadata"
            )
            data = response.json()
        - lang: javascript
          label: Get Replica Commands Metadata
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/metadata");

            const data = await response.json();
      description: >-
        Retrieves metadata describing the dataset, including its name, aliases,
        start block, and real-time status.
      responses:
        '200':
          description: Dataset metadata response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetMetadata'
        '404':
          description: Dataset not found (`error.code` is `unknown_dataset`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: unknown_dataset
                  message: 'Unknown dataset: no-such-chain'
  /stream:
    post:
      summary: Stream Blocks
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/stream
        metadata:
          description: Stream Hyperliquid replica command data with the SQD Portal API.
      x-codeSamples:
        - lang: shell
          label: Get user trading actions (orders, cancels, etc.)
          source: >
            curl --compressed -X POST
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/stream' \
              -H 'Content-Type: application/json' \
              -d '{
                "type": "hyperliquidReplicaCmds",
                "fromBlock": 880000000,
                "toBlock": 880000002,
                "fields": {
                  "block": {
                    "number": true,
                    "timestamp": true
                  },
                  "action": {
                    "actionIndex": true,
                    "user": true,
                    "action": true,
                    "status": true,
                    "response": true,
                    "nonce": true
                  }
                },
                "actions": [{
                  "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                }]
              }'
        - lang: python
          label: Get user trading actions (orders, cancels, etc.)
          source: |
            import requests

            response = requests.post(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/stream",
                json={
                    "type": "hyperliquidReplicaCmds",
                    "fromBlock": 880000000,
                    "toBlock": 880000002,
                    "fields": {
                        "block": {
                            "number": True,
                            "timestamp": True
                        },
                        "action": {
                            "actionIndex": True,
                            "user": True,
                            "action": True,
                            "status": True,
                            "response": True,
                            "nonce": True
                        }
                    },
                    "actions": [{
                        "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                    }]
                }
            )
            data = response.json()
        - lang: javascript
          label: Get user trading actions (orders, cancels, etc.)
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/stream",
            {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({
                    "type": "hyperliquidReplicaCmds",
                    "fromBlock": 880000000,
                    "toBlock": 880000002,
                    "fields": {
                        "block": {
                            "number": true,
                            "timestamp": true
                        },
                        "action": {
                            "actionIndex": true,
                            "user": true,
                            "action": true,
                            "status": true,
                            "response": true,
                            "nonce": true
                        }
                    },
                    "actions": [{
                        "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                    }]
                })
            });

            const data = await response.json();
      description: >-
        Streams a list of blocks matching the provided data query, potentially
        including real-time data. Required request headers: `Content-Type:
        application/json`; optional request headers: `Accept-Encoding: gzip`,
        `Content-Encoding: gzip`.
      requestBody:
        description: >-
          Data query to filter and retrieve blocks. Request body may be gzipped
          (Content-Encoding: gzip).
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataQuery'
            examples:
              user-actions:
                summary: >-
                  Get trading actions for a specific user (orders, cancels,
                  etc.)
                value:
                  type: hyperliquidReplicaCmds
                  fromBlock: 880000000
                  toBlock: 880000002
                  fields:
                    block:
                      number: true
                      timestamp: true
                    action:
                      actionIndex: true
                      user: true
                      action: true
                      status: true
                      response: true
                      nonce: true
                  actions:
                    - user:
                        - '0x010461c14e146ac35fe42271bdc1134ee31c703a'
      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.
          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 chain as this block.
              required: false
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Block'
              examples:
                user-actions-response:
                  summary: User trading actions response
                  value:
                    - header:
                        number: 880000001
                        timestamp: 1710000000000
                      actions:
                        - actionIndex: 0
                          user: '0x010461c14e146ac35fe42271bdc1134ee31c703a'
                          action:
                            type: order
                            orders:
                              - a: 3
                                b: true
                                p: '67234.5'
                                s: '0.1'
                                r: false
                                t:
                                  limit:
                                    tif: Gtc
                          status: ok
                          response:
                            type: order
                            data:
                              statuses:
                                - resting:
                                    oid: 12345678
                          nonce: 1710000000000
        '204':
          description: >-
            No new blocks available in the requested range - the range is
            entirely above the current dataset head. Not an error and the
            response has no body; wait and retry to keep following the chain
            head. The portal may wait for up to 5s before returning this.
          content:
            text/plain:
              schema:
                type: string
              example: No new blocks available in the requested range
          headers:
            X-Sqd-Finalized-Head-Number:
              schema:
                type: integer
                format: int64
              required: false
            X-Sqd-Finalized-Head-Hash:
              schema:
                type: string
              required: false
        '400':
          description: >
            Invalid request or query (`error.code` is `malformed_request`;
            `error.param` names the request field at fault when one is).
            Possible causes: (1) request headers or body encoding are incorrect;
            (2) the query is invalid - `error.message` includes an explanation;
            (3) fromBlock is below the dataset's start_block (see /metadata).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: malformed_request
                  message: 'Bad request: fromBlock must be a non-negative integer'
                  param: fromBlock
        '404':
          description: Dataset not found (`error.code` is `unknown_dataset`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: unknown_dataset
                  message: 'Unknown dataset: no-such-chain'
        '409':
          description: >-
            Parent block hash mismatch (`error.code` is `base_block_mismatch`) -
            the query's parentBlockHash does not match the canonical parent of
            the first requested block, typically after a chain reorganization.
            Walk the top-level previousBlocks list to find the most recent block
            you have already processed, roll back your data to it, then resume
            the stream from the next block, passing that block's hash as
            parentBlockHash. If nothing in the list matches your records,
            restart from an earlier fromBlock, again with parentBlockHash.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictResponse'
        '429':
          description: >-
            Rate limited (`error.type` is `rate_limit_error`). Retry after the
            interval in the Retry-After header; it is always present and counts
            seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '500':
          description: >-
            Internal server error (`error.type` is `api_error`). Do not retry;
            report the error together with its request_id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: api_error
                  code: internal_error
                  message: Internal server error
                  request_id: 0198c3f1-...
        '502':
          description: >-
            A data source the Portal depends on is unavailable (`error.code` is
            `upstream_unavailable`) - retry later. A proxied upstream failure
            keeps the upstream's own 5xx status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: upstream_unavailable
                  message: Upstream data source is unavailable, please try again later
                  request_id: 0198c3f1-...
        '503':
          description: >-
            Service temporarily unavailable (`error.type` is
            `availability_error`, typically `no_workers` or `retries_exhausted`)
            - retry later. May carry Retry-After; honor it when present
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: no_workers
                  message: No workers available for dataset
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '529':
          description: >-
            Overloaded (`error.code` is `overloaded`) - the Portal or a data
            source is at capacity. Retry after the interval in the Retry-After
            header; it is always present and counts seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
  /finalized-stream:
    post:
      summary: Stream Finalized Blocks
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/finalized-stream
        metadata:
          description: >-
            Stream finalized Hyperliquid replica command data with the SQD
            Portal API.
      x-codeSamples:
        - lang: shell
          label: Get user trading actions (orders, cancels, etc.)
          source: >
            curl --compressed -X POST
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-stream'
            \
              -H 'Content-Type: application/json' \
              -d '{
                "type": "hyperliquidReplicaCmds",
                "fromBlock": 880000000,
                "toBlock": 880000002,
                "fields": {
                  "block": {
                    "number": true,
                    "timestamp": true
                  },
                  "action": {
                    "actionIndex": true,
                    "user": true,
                    "action": true,
                    "status": true,
                    "response": true,
                    "nonce": true
                  }
                },
                "actions": [{
                  "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                }]
              }'
        - lang: python
          label: Get user trading actions (orders, cancels, etc.)
          source: |
            import requests

            response = requests.post(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-stream",
                json={
                    "type": "hyperliquidReplicaCmds",
                    "fromBlock": 880000000,
                    "toBlock": 880000002,
                    "fields": {
                        "block": {
                            "number": True,
                            "timestamp": True
                        },
                        "action": {
                            "actionIndex": True,
                            "user": True,
                            "action": True,
                            "status": True,
                            "response": True,
                            "nonce": True
                        }
                    },
                    "actions": [{
                        "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                    }]
                }
            )
            data = response.json()
        - lang: javascript
          label: Get user trading actions (orders, cancels, etc.)
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-stream",
            {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({
                    "type": "hyperliquidReplicaCmds",
                    "fromBlock": 880000000,
                    "toBlock": 880000002,
                    "fields": {
                        "block": {
                            "number": true,
                            "timestamp": true
                        },
                        "action": {
                            "actionIndex": true,
                            "user": true,
                            "action": true,
                            "status": true,
                            "response": true,
                            "nonce": true
                        }
                    },
                    "actions": [{
                        "user": ["0x010461c14e146ac35fe42271bdc1134ee31c703a"]
                    }]
                })
            });

            const data = await response.json();
      description: >-
        Streams only finalized blocks matching the provided data query
        (finalized data does not reorganize; a 409 here only means the provided
        parentBlockHash is stale). Query structure is identical to that of the
        /stream endpoint. Required request headers: `Content-Type:
        application/json`; optional request headers: `Accept-Encoding: gzip`,
        `Content-Encoding: gzip`.
      requestBody:
        description: >-
          Data query to filter and retrieve finalized blocks. Request body may
          be gzipped (Content-Encoding: gzip).
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataQuery'
            examples:
              user-actions:
                summary: >-
                  Get trading actions for a specific user (orders, cancels,
                  etc.)
                value:
                  type: hyperliquidReplicaCmds
                  fromBlock: 880000000
                  toBlock: 880000002
                  fields:
                    block:
                      number: true
                      timestamp: true
                    action:
                      actionIndex: true
                      user: true
                      action: true
                      status: true
                      response: true
                      nonce: true
                  actions:
                    - user:
                        - '0x010461c14e146ac35fe42271bdc1134ee31c703a'
      responses:
        '200':
          description: >-
            A stream of finalized blocks in JSON lines format, optionally
            gzipped.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Block'
              examples:
                user-actions-response:
                  summary: User trading actions response
                  value:
                    - header:
                        number: 880000001
                        timestamp: 1710000000000
                      actions:
                        - actionIndex: 0
                          user: '0x010461c14e146ac35fe42271bdc1134ee31c703a'
                          action:
                            type: order
                            orders:
                              - a: 3
                                b: true
                                p: '67234.5'
                                s: '0.1'
                                r: false
                                t:
                                  limit:
                                    tif: Gtc
                          status: ok
                          response:
                            type: order
                            data:
                              statuses:
                                - resting:
                                    oid: 12345678
                          nonce: 1710000000000
        '204':
          description: >-
            No new blocks available in the requested range - the range is
            entirely above the current dataset head. Not an error and the
            response has no body; wait and retry to keep following the chain
            head. The portal may wait for up to 5s before returning this.
          content:
            text/plain:
              schema:
                type: string
              example: No new blocks available in the requested range
        '400':
          description: >
            Invalid request or query (`error.code` is `malformed_request`;
            `error.param` names the request field at fault when one is).
            Possible causes: (1) request headers or body encoding are incorrect;
            (2) the query is invalid - `error.message` includes an explanation;
            (3) fromBlock is below the dataset's start_block (see /metadata).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: malformed_request
                  message: 'Bad request: fromBlock must be a non-negative integer'
                  param: fromBlock
        '404':
          description: Dataset not found (`error.code` is `unknown_dataset`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: unknown_dataset
                  message: 'Unknown dataset: no-such-chain'
        '409':
          description: >-
            Parent block hash mismatch (`error.code` is `base_block_mismatch`).
            Finalized data does not reorganize, so the provided parentBlockHash
            is stale or was carried over from an unfinalized block. Recover as
            for /stream by walking the top-level previousBlocks list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConflictResponse'
        '429':
          description: >-
            Rate limited (`error.type` is `rate_limit_error`). Retry after the
            interval in the Retry-After header; it is always present and counts
            seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '500':
          description: >-
            Internal server error (`error.type` is `api_error`). Do not retry;
            report the error together with its request_id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: api_error
                  code: internal_error
                  message: Internal server error
                  request_id: 0198c3f1-...
        '502':
          description: >-
            A data source the Portal depends on is unavailable (`error.code` is
            `upstream_unavailable`) - retry later. A proxied upstream failure
            keeps the upstream's own 5xx status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: upstream_unavailable
                  message: Upstream data source is unavailable, please try again later
                  request_id: 0198c3f1-...
        '503':
          description: >-
            Service temporarily unavailable (`error.type` is
            `availability_error`, typically `no_workers` or `retries_exhausted`)
            - retry later. May carry Retry-After; honor it when present
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: no_workers
                  message: No workers available for dataset
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '529':
          description: >-
            Overloaded (`error.code` is `overloaded`) - the Portal or a data
            source is at capacity. Retry after the interval in the Retry-After
            header; it is always present and counts seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
  /head:
    get:
      summary: Latest Block
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/head
        metadata:
          description: >-
            Get the latest block for Hyperliquid replica commands from SQD
            Portal.
      x-codeSamples:
        - lang: shell
          label: Get Latest Block for Replica Commands
          source: >
            curl --compressed
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/head'
        - lang: python
          label: Get Latest Block for Replica Commands
          source: |
            import requests

            response = requests.get(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/head"
            )
            data = response.json()
        - lang: javascript
          label: Get Latest Block for Replica Commands
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/head");

            const data = await response.json();
      description: >-
        Returns the block number and hash of the highest block available in the
        dataset, or null if no blocks are available. Takes real-time data into
        account. Useful mostly for diagnostics, as clients using /stream can get
        this info from the X-Sqd-Finalized-Head-Number and
        X-Sqd-Finalized-Head-Hash response headers.
      responses:
        '200':
          description: Highest block information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockHead'
        '404':
          description: Dataset not found (`error.code` is `unknown_dataset`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: unknown_dataset
                  message: 'Unknown dataset: no-such-chain'
  /finalized-head:
    get:
      summary: Latest Finalized Block
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/finalized-head
        metadata:
          description: >-
            Get the latest finalized block for Hyperliquid replica commands from
            SQD Portal.
      x-codeSamples:
        - lang: shell
          label: Get Latest Finalized Block for Replica Commands
          source: >
            curl --compressed
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-head'
        - lang: python
          label: Get Latest Finalized Block for Replica Commands
          source: |
            import requests

            response = requests.get(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-head"
            )
            data = response.json()
        - lang: javascript
          label: Get Latest Finalized Block for Replica Commands
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/finalized-head");

            const data = await response.json();
      description: >-
        Returns the block number and hash of the highest finalized block
        available in the dataset, or null if no blocks are available. Useful
        mostly for diagnostics, as clients using /stream can get this info from
        the X-Sqd-Finalized-Head-Number and X-Sqd-Finalized-Head-Hash response
        headers.
      responses:
        '200':
          description: Highest finalized block information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockHead'
        '404':
          description: Dataset not found (`error.code` is `unknown_dataset`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: unknown_dataset
                  message: 'Unknown dataset: no-such-chain'
  /timestamps/{timestamp}/block:
    get:
      summary: Block at Timestamp
      x-mint:
        href: /en/api/hyperliquid-replica-cmds/timestamp-block
        metadata:
          description: >-
            Resolve a Unix timestamp to a Hyperliquid replica commands block
            with the SQD Portal API.
      x-codeSamples:
        - lang: shell
          label: Resolve timestamp to block
          source: >
            curl
            'https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/timestamps/1700000000/block'
        - lang: python
          label: Resolve timestamp to block
          source: |
            import requests

            response = requests.get(
                "https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/timestamps/1700000000/block"
            )
            block_number = response.json()["block_number"]
        - lang: javascript
          label: Resolve timestamp to block
          source: >
            const response = await
            fetch("https://portal.sqd.dev/datasets/hyperliquid-replica-cmds/timestamps/1700000000/block");

            const { block_number } = await response.json();
      description: >
        Resolves a Unix timestamp (in seconds) to a block number. Returns the
        first block whose timestamp is greater than or equal to `timestamp`.
        Resolution prefers archival data and falls back to the real-time source
        when available; the `x-sqd-data-source` response header reports which
        source served the result (`network` or `real_time`).
      parameters:
        - name: timestamp
          in: path
          required: true
          schema:
            type: integer
            format: int64
            default: 1700000000
            example: 1700000000
          description: Unix timestamp in seconds.
      responses:
        '200':
          description: Block number resolved.
          headers:
            x-sqd-data-source:
              schema:
                type: string
                enum:
                  - network
                  - real_time
              description: Source that served the result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockNumberResponse'
              examples:
                hyperliquid-replica-cmds:
                  summary: First block at or after the timestamp
                  value:
                    block_number: 868700000
        '400':
          description: >-
            Unparseable `timestamp` path segment (`error.code` is
            `malformed_request`), or the real-time source refused the query the
            Portal generated on the client's behalf; read `error.message`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: malformed_request
                  message: 'Bad request: fromBlock must be a non-negative integer'
                  param: fromBlock
        '404':
          description: >-
            No block at or after the given timestamp yet (`error.code` is
            `not_found`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: invalid_request_error
                  code: not_found
                  message: No block at or after the given timestamp
        '429':
          description: >-
            Rate limited (`error.type` is `rate_limit_error`). Retry after the
            interval in the Retry-After header; it is always present and counts
            seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '500':
          description: >-
            Internal server error (`error.type` is `api_error`). Do not retry;
            report the error together with its request_id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: api_error
                  code: internal_error
                  message: Internal server error
                  request_id: 0198c3f1-...
        '502':
          description: >-
            A data source the Portal depends on is unavailable (`error.code` is
            `upstream_unavailable`) - retry later. A proxied upstream failure
            keeps the upstream's own 5xx status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: upstream_unavailable
                  message: Upstream data source is unavailable, please try again later
                  request_id: 0198c3f1-...
        '503':
          description: >-
            Service temporarily unavailable (`error.type` is
            `availability_error`, typically `no_workers` or `retries_exhausted`)
            - retry later. May carry Retry-After; honor it when present
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: availability_error
                  code: no_workers
                  message: No workers available for dataset
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
        '529':
          description: >-
            Overloaded (`error.code` is `overloaded`) - the Portal or a data
            source is at capacity. Retry after the interval in the Retry-After
            header; it is always present and counts seconds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  type: rate_limit_error
                  code: overloaded
                  message: Service is overloaded, please try again later
                  request_id: 0198c3f1-...
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying (at least 1)
components:
  schemas:
    BlockNumberResponse:
      type: object
      properties:
        block_number:
          type: integer
          format: int64
          description: >-
            Number of the first block whose timestamp is greater than or equal
            to the requested timestamp.
          example: 18000000
      required:
        - block_number
    DatasetMetadata:
      type: object
      properties:
        dataset:
          type: string
          description: The default name used to reference this dataset.
        aliases:
          type: array
          items:
            type: string
          description: Alternative names for the dataset.
        real_time:
          type: boolean
          description: Indicates if the dataset has real-time data.
        start_block:
          type: integer
          format: int64
          description: The block number of the first known block.
      required:
        - dataset
        - aliases
        - real_time
    DatasetState:
      type: object
      properties:
        worker_ranges:
          type: object
          description: Keys are workers' peer IDs.
          additionalProperties:
            type: object
            properties:
              ranges:
                type: array
                items:
                  type: object
                  properties:
                    begin:
                      type: integer
                      format: int64
                    end:
                      type: integer
                      format: int64
                  required:
                    - begin
                    - end
        highest_seen_block:
          type: integer
          format: uint64
        first_gap:
          type: integer
          format: uint64
      required:
        - worker_ranges
        - highest_seen_block
    DataQuery:
      type: object
      properties:
        type:
          type: string
          enum:
            - hyperliquidReplicaCmds
          default: hyperliquidReplicaCmds
          description: The type of data (fixed to hyperliquidReplicaCmds 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.
                round:
                  type: boolean
                  description: Include the HyperBFT consensus round number.
                parentRound:
                  type: boolean
                  description: Include the parent block's consensus round number.
                proposer:
                  type: boolean
                  description: Include the validator address that proposed this block.
                timestamp:
                  type: boolean
                  description: Include the block timestamp.
                hardfork:
                  type: boolean
                  description: Include hardfork activation details, if any.
              default:
                number: true
                hash: true
                parentHash: true
            action:
              type: object
              description: Field selector for actions.
              properties:
                actionIndex:
                  type: boolean
                  description: Include the action index within the block.
                user:
                  type: boolean
                  description: Include the wallet address that submitted the action.
                action:
                  type: boolean
                  description: Include the action payload (order, cancel, transfer, etc.).
                signature:
                  type: boolean
                  description: Include the EIP-712 or L1 action signature.
                nonce:
                  type: boolean
                  description: Include the action sequence nonce.
                vaultAddress:
                  type: boolean
                  description: >-
                    Include the vault address if the action was submitted on
                    behalf of a vault.
                status:
                  type: boolean
                  description: Include the exchange processing result (ok or err).
                response:
                  type: boolean
                  description: Include the exchange response payload.
        actions:
          type: array
          description: >
            Generic action data requests. An empty object matches all actions;
            an empty array matches no actions. To filter by specialized action
            subtypes (orders, cancels, batch modifies), use the dedicated
            request arrays instead.
          items:
            type: object
            properties:
              actionType:
                type: array
                items:
                  type: string
                description: >
                  Action type strings to filter by (e.g., "order", "cancel",
                  "cancelByCloid", "batchModify", "transfer", "withdraw",
                  "updateLeverage").
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              vaultAddress:
                type: array
                items:
                  type: string
                description: >-
                  Vault addresses (0x-prefixed hex, lowercase) to filter by.
                  Matches actions submitted on behalf of a vault.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: >-
                  Filter by action outcome. "ok" for successfully processed
                  actions, "err" for rejected actions.
        orderActions:
          type: array
          description: >
            Order action requests. Filters actions that contain order placements
            matching the given criteria. An empty object matches all order
            actions; an empty array matches none.
          items:
            type: object
            properties:
              containsAsset:
                type: array
                items:
                  type: integer
                  format: uint32
                description: >-
                  Asset indices to filter by. Matches order actions containing
                  at least one order for any of the given assets.
              containsCloid:
                type: array
                items:
                  type: string
                description: >-
                  Client order IDs (0x-prefixed hex) to filter by. Matches order
                  actions containing at least one order with any of the given
                  cloids.
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              vaultAddress:
                type: array
                items:
                  type: string
                description: Vault addresses (0x-prefixed hex, lowercase) to filter by.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: Filter by action outcome.
        cancelActions:
          type: array
          description: >
            Cancel action requests. Filters actions that contain order
            cancellations matching the given criteria. An empty object matches
            all cancel actions; an empty array matches none.
          items:
            type: object
            properties:
              containsAsset:
                type: array
                items:
                  type: integer
                  format: uint32
                description: >-
                  Asset indices to filter by. Matches cancel actions containing
                  at least one cancellation for any of the given assets.
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              vaultAddress:
                type: array
                items:
                  type: string
                description: Vault addresses (0x-prefixed hex, lowercase) to filter by.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: Filter by action outcome.
        cancelByCloidActions:
          type: array
          description: >
            Cancel-by-client-order-ID action requests. Filters cancellation
            actions referencing specific client order IDs. An empty object
            matches all such actions; an empty array matches none.
          items:
            type: object
            properties:
              containsAsset:
                type: array
                items:
                  type: integer
                  format: uint32
                description: Asset indices to filter by.
              containsCloid:
                type: array
                items:
                  type: string
                description: Client order IDs (0x-prefixed hex) to filter by.
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              vaultAddress:
                type: array
                items:
                  type: string
                description: Vault addresses (0x-prefixed hex, lowercase) to filter by.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: Filter by action outcome.
        batchModifyActions:
          type: array
          description: >
            Batch modify action requests. Filters actions that contain batch
            order modifications. An empty object matches all batch modify
            actions; an empty array matches none.
          items:
            type: object
            properties:
              containsAsset:
                type: array
                items:
                  type: integer
                  format: uint32
                description: Asset indices to filter by.
              containsCloid:
                type: array
                items:
                  type: string
                description: Client order IDs (0x-prefixed hex) to filter by.
              user:
                type: array
                items:
                  type: string
                description: >-
                  Trader wallet addresses (0x-prefixed hex, lowercase) to filter
                  by.
              vaultAddress:
                type: array
                items:
                  type: string
                description: Vault addresses (0x-prefixed hex, lowercase) to filter by.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: Filter by action outcome.
      required:
        - type
        - fromBlock
    Block:
      type: object
      properties:
        header:
          type: object
          description: >-
            Block header data. Fields are conditionally returned based on the
            `fields.block` parameter.
          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).
            round:
              type: integer
              format: uint64
              description: >-
                HyperBFT consensus round number in which this block was
                proposed.
            parentRound:
              type: integer
              format: uint64
              description: Consensus round of the parent block.
            proposer:
              type: string
              description: Validator address that proposed this block (0x-prefixed hex).
            timestamp:
              type: integer
              format: uint64
              description: Block timestamp in milliseconds since Unix epoch.
            hardfork:
              type: object
              nullable: true
              description: >-
                Hardfork activation details at this block, if any. Null for
                normal blocks.
        actions:
          type: array
          description: >-
            Blockchain actions included in this block. Fields are conditionally
            returned based on the `fields.action` parameter.
          items:
            type: object
            properties:
              actionIndex:
                type: integer
                format: uint64
                description: Index of the action within the block.
              user:
                type: string
                description: >-
                  Trader wallet address that submitted the action (0x-prefixed
                  hex, lowercase).
              action:
                type: object
                description: >
                  The action payload as JSON. The structure varies by action
                  type. Common types include orders, cancels, transfers,
                  leverage updates, and vault operations.
              signature:
                type: object
                description: >
                  The EIP-712 or L1 action signature as JSON, containing
                  signature fields (r, s, v) and the nonce used for signing.
              nonce:
                type: integer
                format: uint64
                nullable: true
                description: >-
                  Action sequence nonce (typically a timestamp in milliseconds
                  at time of signing).
              vaultAddress:
                type: string
                nullable: true
                description: >-
                  Vault address if this action was submitted on behalf of a
                  vault (0x-prefixed hex, lowercase). Null for direct user
                  actions.
              status:
                type: string
                enum:
                  - ok
                  - err
                description: >-
                  Exchange processing result. "ok" if the action was accepted,
                  "err" if rejected.
              response:
                type: object
                description: >-
                  Exchange response payload as JSON. Contains status details and
                  any result data (e.g., order IDs for placed orders).
      required:
        - header
    BlockHead:
      type: object
      properties:
        number:
          type: integer
          format: int64
          description: Block number of the highest available block.
        hash:
          type: string
          description: Hash of the highest available block.
      nullable: true
    ErrorDetail:
      type: object
      description: >-
        Machine-readable error detail. Branch on `type`; match on `code` for one
        specific case.
      properties:
        type:
          type: string
          description: >-
            Coarse category to branch on. One of `invalid_request_error`,
            `rate_limit_error`, `availability_error`, or `api_error`. Treat an
            unknown `code` according to its `type`.
          example: invalid_request_error
        code:
          type: string
          description: >-
            Specific cause, stable across releases. Match on this rather than on
            `message`.
          example: base_block_mismatch
        message:
          type: string
          description: >-
            Human-readable detail. Prose, not stable; do not parse or match on
            it.
        param:
          type: string
          description: The request parameter at fault, when the error is about one.
        request_id:
          type: string
          description: >-
            Echo of the `x-request-id` response header, included in the body on
            5xx errors. Quote it when reporting a problem.
      required:
        - type
        - code
        - message
    ErrorResponse:
      type: object
      description: Error body shared by every failing response.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      example:
        error:
          type: invalid_request_error
          code: unknown_dataset
          message: 'Unknown dataset: no-such-chain'
    ConflictResponse:
      type: object
      description: >-
        The 409 body carries the standard error envelope plus a top-level
        `previousBlocks` list - a slice of the current canonical chain at and
        below the conflict point, in ascending block-number order.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
        previousBlocks:
          type: array
          description: >-
            `{ number, hash }` pairs from the current canonical chain in
            ascending order; the last entry is the most recent block at or below
            the conflict point. Guaranteed to contain at least the parent of the
            requested fromBlock.
          items:
            type: object
            properties:
              number:
                type: integer
                format: int64
              hash:
                type: string
            required:
              - number
              - hash
      required:
        - error
        - previousBlocks
      example:
        error:
          type: invalid_request_error
          code: base_block_mismatch
          message: Base block mismatch
        previousBlocks:
          - number: 21780871
            hash: 0xab12cd...
          - number: 21780872
            hash: 0xf6a96a29...
