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

# POST /stream

> 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`




## OpenAPI

````yaml /api-reference/openapi.yaml post /stream
openapi: 3.1.0
info:
  title: SQD Network Portal API - Dataset Endpoints
  description: >-
    API endpoints for interacting with datasets under the SQD Network Portal,
    specifically for the solana-mainnet dataset.
  version: 1.0.0
servers:
  - url: https://portal.sqd.dev/datasets/solana-mainnet
security: []
paths:
  /stream:
    post:
      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
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataQuery'
      responses:
        '200':
          description: >-
            A stream of blocks in JSON lines format, optionally gzipped. Can
            only 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: >-
                Slot number of the latest finalized block. Returned blocks can
                be above, at or below this slot 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'
        '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: >-
                Slot number of the latest finalized block. Returned blocks can
                be above, at or below this slot 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
        '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 slot 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
components:
  schemas:
    DataQuery:
      type: object
      properties:
        type:
          type: string
          enum:
            - solana
          default: solana
        fromBlock:
          type: integer
          format: int64
          description: >-
            The number of the first block to fetch. If unsure how far into the
            past this can go consult /metadata
          default: 317617480
        toBlock:
          type: integer
          format: int64
          description: The number of the last block to fetch (inclusive)
          default: 317617482
        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
        fields:
          type: object
          description: >-
            Field selector. See the HTTP 200 response description for details on
            fields that aren't self-explanatory
          properties:
            instruction:
              type: object
              description: Field selector for instructions
              properties:
                transactionIndex:
                  type: boolean
                instructionAddress:
                  type: boolean
                programId:
                  type: boolean
                accounts:
                  type: boolean
                data:
                  type: boolean
                d1:
                  type: boolean
                d2:
                  type: boolean
                d4:
                  type: boolean
                d8:
                  type: boolean
                error:
                  type: boolean
                computeUnitsConsumed:
                  type: boolean
                isCommitted:
                  type: boolean
                hasDroppedLogMessages:
                  type: boolean
            transaction:
              type: object
              description: Field selector for transactions
              properties:
                transactionIndex:
                  type: boolean
                version:
                  type: boolean
                accountKeys:
                  type: boolean
                addressTableLookups:
                  type: boolean
                numReadonlySignedAccounts:
                  type: boolean
                numReadonlyUnsignedAccounts:
                  type: boolean
                numRequiredSignatures:
                  type: boolean
                recentBlockhash:
                  type: boolean
                signatures:
                  type: boolean
                err:
                  type: boolean
                fee:
                  type: boolean
                computeUnitsConsumed:
                  type: boolean
                loadedAddresses:
                  type: boolean
                feePayer:
                  type: boolean
                hasDroppedLogMessages:
                  type: boolean
            log:
              type: object
              description: Field selector for log messages
              properties:
                transactionIndex:
                  type: boolean
                logIndex:
                  type: boolean
                instructionAddress:
                  type: boolean
                programId:
                  type: boolean
                kind:
                  type: boolean
                message:
                  type: boolean
            balance:
              type: object
              description: Field selector for SOL balance updates
              properties:
                transactionIndex:
                  type: boolean
                account:
                  type: boolean
                pre:
                  type: boolean
                post:
                  type: boolean
            tokenBalance:
              type: object
              description: Field selector for token balance updates
              properties:
                transactionIndex:
                  type: boolean
                account:
                  type: boolean
                preMint:
                  type: boolean
                postMint:
                  type: boolean
                preDecimals:
                  type: boolean
                postDecimals:
                  type: boolean
                preProgramId:
                  type: boolean
                postProgramId:
                  type: boolean
                preOwner:
                  type: boolean
                postOwner:
                  type: boolean
                preAmount:
                  type: boolean
                postAmount:
                  type: boolean
            reward:
              type: object
              description: Field selector for rewards
              properties:
                pubKey:
                  type: boolean
                lamports:
                  type: boolean
                postBalance:
                  type: boolean
                rewardType:
                  type: boolean
                commission:
                  type: boolean
            block:
              type: object
              description: >-
                Field selector for block headers (the .header objects of JSON
                block records)
              properties:
                number:
                  type: boolean
                height:
                  type: boolean
                parentSlot:
                  type: boolean
                timestamp:
                  type: boolean
          default:
            instruction:
              data: true
            block:
              number: true
        instructions:
          type: array
          default:
            - programId:
                - dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH
          description: >-
            Instruction data requests. Selects instructions found anywhere in
            the call tree, not just the top level ones. d1-d8 filter by the
            starting bytes of the data (in 0x-prefixed hex format); a0-a15
            filter by account at the corresponding position in the accounts
            array; mentionsAccount filters by account mentions anywhere in the
            list
          items:
            type: object
            properties:
              programId:
                type: array
                items:
                  type: string
              d1:
                description: >-
                  Accepted values for the first byte of the data in 0x-prefixed
                  hex format
                type: array
                items:
                  type: string
              d2:
                description: >-
                  Accepted values for the first two bytes of the data in
                  0x-prefixed hex format
                type: array
                items:
                  type: string
              d3:
                description: >-
                  Accepted values for the first three bytes of the data in
                  0x-prefixed hex format
                type: array
                items:
                  type: string
              d4:
                description: >-
                  Accepted values for the first four bytes of the data in
                  0x-prefixed hex format
                type: array
                items:
                  type: string
              d8:
                description: >-
                  Accepted values for the first eight bytes of the data in
                  0x-prefixed hex format
                type: array
                items:
                  type: string
              mentionsAccount:
                description: >-
                  Selects instructions that mention a given account anywhere in
                  their account lists, including at the positions higher than
                  these accessible by the a* filters listed below
                type: array
                items:
                  type: string
              a0:
                type: array
                items:
                  type: string
              a1:
                type: array
                items:
                  type: string
              a2:
                type: array
                items:
                  type: string
              a3:
                type: array
                items:
                  type: string
              a4:
                type: array
                items:
                  type: string
              a5:
                type: array
                items:
                  type: string
              a6:
                type: array
                items:
                  type: string
              a7:
                type: array
                items:
                  type: string
              a8:
                type: array
                items:
                  type: string
              a9:
                type: array
                items:
                  type: string
              a10:
                type: array
                items:
                  type: string
              a11:
                type: array
                items:
                  type: string
              a12:
                type: array
                items:
                  type: string
              a13:
                type: array
                items:
                  type: string
              a14:
                type: array
                items:
                  type: string
              a15:
                type: array
                items:
                  type: string
              isCommitted:
                type: boolean
              transaction:
                description: Fetch parent transactions for all matching instructions
                type: boolean
              transactionBalances:
                description: >-
                  Fetch SOL balance updates caused by parent transactions of all
                  matching instructions
                type: boolean
              transactionTokenBalances:
                description: >-
                  Fetch token balance updates caused by parent transactions of
                  all matching instructions
                type: boolean
              transactionInstructions:
                description: >-
                  Fetch all "sibling" instructions / instructions executed by
                  parent transactions of all matching instructions
                type: boolean
              innerInstructions:
                description: >-
                  Fetch all instructions called by matching instructions (entire
                  subtrees, not just the ones called directly)
                type: boolean
              logs:
                description: >-
                  Fetch logs produced by matching instructions. Read
                  https://docs.soldexer.dev/api-reference/data-notes/logs-truncation
                  before attempting to use logs
                type: boolean
        transactions:
          type: array
          description: Transaction data requests
          items:
            type: object
            properties:
              feePayer:
                type: array
                items:
                  type: string
              mentionsAccount:
                type: array
                items:
                  type: string
              instructions:
                description: Fetch all instructions executed in the matching transactions
                type: boolean
              balances:
                description: Fetch all SOL balance updates due to the matching transactions
                type: boolean
              tokenBalances:
                description: >-
                  Fetch all token balance updates due to the matching
                  transactions
                type: boolean
              logs:
                description: >-
                  Fetch all logs produced by the matching transactions. Read
                  https://docs.soldexer.dev/api-reference/data-notes/logs-truncation
                  before attempting to use logs
                type: boolean
        balances:
          type: array
          description: Requests for SOL balance updates
          items:
            type: object
            properties:
              account:
                type: array
                items:
                  type: string
              transaction:
                description: Fetch parent transactions for all matching balance updates
                type: boolean
              transactionInstructions:
                description: >-
                  Fetch all instructions executed by parent transactions of all
                  matching balance updates
                type: boolean
        tokenBalances:
          type: array
          description: Requests for token balance updates
          items:
            type: object
            properties:
              account:
                type: array
                items:
                  type: string
              preProgramId:
                type: array
                items:
                  type: string
              postProgramId:
                type: array
                items:
                  type: string
              preMint:
                type: array
                items:
                  type: string
              postMint:
                type: array
                items:
                  type: string
              preOwner:
                type: array
                items:
                  type: string
              postOwner:
                type: array
                items:
                  type: string
              transaction:
                description: Fetch parent transactions for all matching balance updates
                type: boolean
              transactionInstructions:
                description: >-
                  Fetch all instructions executed by parent transactions of all
                  matching balance updates
                type: boolean
        rewards:
          type: array
          description: Reward data requests
          items:
            type: object
            properties:
              pubkey:
                type: array
                items:
                  type: string
        logs:
          type: array
          description: >
            Logs data requests. Read
            https://docs.soldexer.dev/api-reference/data-notes/logs-truncation
            before attempting to use logs
          items:
            type: object
            properties:
              programId:
                type: array
                items:
                  type: string
              kind:
                type: array
                items:
                  type: string
                  enum:
                    - log
                    - data
                    - other
              instruction:
                description: Fetch parent instructions for all matching logs
                type: boolean
              transaction:
                description: Fetch parent transactions for all matching logs
                type: boolean
      required:
        - fromBlock
    Block:
      type: object
      properties:
        header:
          type: object
          properties:
            number:
              type: integer
              format: uint64
            height:
              type: integer
              format: uint64
            parentSlot:
              type: integer
              format: uint64
            hash:
              type: string
        instructions:
          type: array
          items:
            type: object
            properties:
              transactionIndex:
                type: integer
              instructionAddress:
                description: >-
                  An array of tree indices addressing the instruction in the
                  call tree. Top level instructions get addresses [0], [1], ...;
                  addresses of length 2 indicate inner instructions directly
                  called by one of the top ones; and so on.
                type: array
                items:
                  type: integer
              programId:
                type: string
              accounts:
                type: array
                items:
                  type: string
              data:
                type: string
              d1:
                description: One byte instruction discriminator
                type: string
              d2:
                description: Two bytes instruction discriminator
                type: string
              d4:
                description: Four bytes instruction discriminator
                type: string
              d8:
                description: Eight bytes instruction discriminator (Anchor standard)
                type: string
              error:
                type: string
              computeUnitsConsumed:
                type: integer
                format: uint64
              isCommitted:
                type: boolean
              hasDroppedLogMessages:
                type: boolean
        transactions:
          type: array
          items:
            type: object
            properties:
              transactionIndex:
                type: integer
              version:
                type: integer
              accountKeys:
                type: array
                items:
                  type: integer
              addressTableLookups:
                type: array
                items:
                  type: object
                  properties:
                    accountKey:
                      type: string
                    readonlyIndexes:
                      type: array
                      items:
                        type: integer
                    writableIndexes:
                      type: array
                      items:
                        type: integer
              numReadonlySignedAccounts:
                type: integer
              numReadonlyUnsignedAccounts:
                type: integer
              numRequiredSignatures:
                type: integer
              recentBlockhash:
                type: string
              signatures:
                description: >-
                  List of transaction signatures. The first one of these is also
                  known as a "transaction hash"
                type: array
                items:
                  type: string
              err:
                type: object
                nullable: true
              fee:
                type: integer
              computeUnitsConsumed:
                type: integer
              loadedAddresses:
                type: object
                properties:
                  readonly:
                    type: array
                    items:
                      type: string
                  writable:
                    type: array
                    items:
                      type: string
              feePayer:
                type: string
              hasDroppedLogMessages:
                type: boolean
        balances:
          type: array
          description: >
            Records of SOL balance updates done per transaction and account.
            Combines pre- and post-balance records, making one record per
            account
          items:
            type: object
            properties:
              transactionIndex:
                type: integer
              account:
                type: string
              pre:
                type: integer
              post:
                type: integer
        tokenBalances:
          type: array
          description: >
            Records of token balance updates done per transaction and token
            account. Uses data from
            https://solana.com/docs/rpc/json-structures#token-balances but
            combines pre- and post-balance records, making one record per token
            account
          items:
            type: object
            properties:
              transactionIndex:
                type: integer
              account:
                description: The token account
                type: string
              preMint:
                description: >-
                  The token mint account. Coincides with postMint when both are
                  defined
                type: string
              postMint:
                description: >-
                  The token mint account. Coincides with preMint when both are
                  defined
                type: string
              preDecimals:
                type: integer
              postDecimals:
                type: integer
              preProgramId:
                type: string
              postProgramId:
                type: string
              preOwner:
                description: The owner of the token account at the start of the transaction
                type: string
              postOwner:
                description: >-
                  The owner of the token account at the end of the transaction.
                  When both pre- and postOwner are defined they can only be
                  different if the transaction has changed the token account
                  owner via the SetAuthority instruction
                type: string
              preAmount:
                type: integer
              postAmount:
                type: integer
        rewards:
          type: array
          items:
            type: object
            properties:
              pubKey:
                type: string
              lamports:
                type: integer
              postBalance:
                type: integer
              rewardType:
                type: string
              commission:
                type: integer
        logs:
          type: array
          description: >
            Read
            https://docs.soldexer.dev/api-reference/data-notes/logs-truncation
            before attempting to use logs
          items:
            type: object
            properties:
              transactionIndex:
                type: integer
              logIndex:
                type: integer
              instructionAddress:
                description: >-
                  Address of the instruction that produced the log. See the
                  instruction field description for details (HTTP 200 response
                  description -> instructions -> instructionAddress)
                type: array
                items:
                  type: integer
              programId:
                type: string
              kind:
                type: string
                enum:
                  - log
                  - data
                  - other
              message:
                type: string
      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

````