> ## Documentation Index
> Fetch the complete documentation index at: https://kraken-sandbox.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Order Book

> Returns level 2 (L2) order book, which describes the individual price levels in the book with aggregated order quantities at each level.




## OpenAPI

````yaml /openapi/spot-rest.yaml get /public/Depth
openapi: 3.0.0
info:
  title: REST API
  version: 1.1.0
  description: ''
servers:
  - url: https://api.kraken.com/0
    description: Production Server
security:
  - API-Key: []
    API-Sign: []
tags:
  - name: Market Data
  - name: Account Data
  - name: Trading
  - name: Funding
  - name: Subaccounts
    description: >-
      Subaccounts are currently only available to institutional clients. Please
      contact your Account Manager for more details.
  - name: Earn
    description: >
      The earn API allows interacting with all of Kraken's yield generating
      products. It replaces the old `/staking` part of the API.


      The different available earn products are represented by earn strategies.
      This corresponds to the legacy `Staking/Assets`. `Stake`/`Unstake` are
      replaced by `Allocate`/`Deallocate`.


      ### Overview of the available endpoints under `/Earn`:


      - `Strategies` - list all earn strategies for which you are eligible or
      have a balance.

      - `Allocations` - lists the balance in your earn account for each
      strategy. Requires the `Query Funds` API key permission.

      - `Allocate`/`Deallocate` - allocate/deallocate to an earn strategy
      through an async operation. Requires the `Earn Funds` API key permission.

      - `AllocateStatus`/`DeallocateStatus` - verifies the state of the last
      allocation/deallocation. Requires the `Earn Funds` or `Query Funds` API
      key permission.


      ### Example usage:


      ### Determine which funds are earning rewards:


      1. Call `Strategies` to obtain information about the relevant strategy.
      The `lock_type` field shows whether bonding/unbonding funds are earning
      yield. The relevant fields are `bonding_rewards`/`unbonding_rewards`.

      2. Call `Allocations` for the relevant strategy. From the previous step,
      for strategies where bonding/unbonding does not earn yield, substract
      these balances from `amount_allocated.total` to determine which balances
      are currently earning.


      ### Get allocatable balance:


      Call `/0/private/BalanceEx`, subtract `hold_trading` amount. Remaining
      balance is available for allocation to a strategy.


      ### Geo restrictions:


      Some earn strategies are not available in all geographic regions.
      `Strategies` will return only strategies available to the caller.
  - name: Transparency
paths:
  /public/Depth:
    get:
      tags:
        - Market Data
      summary: Get Order Book
      description: >
        Returns level 2 (L2) order book, which describes the individual price
        levels in the book with aggregated order quantities at each level.
      operationId: getOrderBook
      parameters:
        - $ref: '#/components/parameters/pair'
        - $ref: '#/components/parameters/assetVersion'
        - name: count
          description: Maximum number of asks/bids
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 100
          example: 2
        - $ref: '#/components/parameters/asset_class'
      responses:
        '200':
          description: Order book entries retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/depth'
                example:
                  error: []
                  result:
                    XXBTZUSD:
                      asks:
                        - - '30384.10000'
                          - '2.059'
                          - 1688671659
                        - - '30387.90000'
                          - '1.500'
                          - 1688671380
                        - - '30393.70000'
                          - '9.871'
                          - 1688671261
                      bids:
                        - - '30297.00000'
                          - '1.115'
                          - 1688671636
                        - - '30296.70000'
                          - '2.002'
                          - 1688671674
                        - - '30289.80000'
                          - '5.001'
                          - 1688671673
      security: []
components:
  parameters:
    pair:
      in: query
      name: pair
      description: Asset pair to get data for
      required: true
      schema:
        type: string
      example: XBTUSD
    assetVersion:
      in: query
      name: assetVersion
      required: false
      schema:
        type: integer
        enum:
          - 1
      description: >
        Controls whether response keys and asset identifier fields use Kraken's
        internal names or display names.


        * Omitted (default): internal names are used. Asset keys use legacy
        `X`/`Z`-prefixed format (`XXBT`, `ZUSD`). Pair keys use the internal
        format (`XXBTZUSD`). Asset identifier fields (`base`, `quote`,
        `fee_volume_currency`) also use internal names.

        * `assetVersion=1`: display names are used. Asset keys become their
        canonical display names (`BTC`, `USD`). Pair keys become the
        slash-separated display format (`BTC/USD`). On `/public/AssetPairs`, the
        `base`, `quote`, and `fee_volume_currency` fields also switch to display
        names.


        Only `assetVersion=1` is currently supported. The `altname` and `wsname`
        fields are not affected by this parameter.
    asset_class:
      name: asset_class
      in: query
      description: >-
        This parameter is required on requests for non-crypto pairs, i.e. use
        `tokenized_asset` for xstocks.
      required: false
      schema:
        type: string
        enum:
          - tokenized_asset
  schemas:
    depth:
      type: object
      properties:
        result:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/orderBookEntry'
            x-additionalPropertiesName: pair
        error:
          $ref: '#/components/schemas/error'
    orderBookEntry:
      title: OrderBook
      description: Asset Pair Order Book Entries
      type: object
      properties:
        asks:
          description: Ask side array of entries `[<price>, <volume>, <timestamp>]`
          type: array
          items:
            type: array
            minItems: 3
            maxItems: 3
            items:
              oneOf:
                - type: string
                  title: string
                - type: integer
                  title: integer
            example:
              - '3539.90000'
              - '0.801'
              - 1548119951
        bids:
          description: Bid side array of entries `[<price>, <volume>, <timestamp>]`
          type: array
          items:
            type: array
            minItems: 3
            maxItems: 3
            items:
              oneOf:
                - type: string
                  title: string
                - type: integer
                  title: integer
            example:
              - '3538.70000'
              - '0.798'
              - 1548119924
    error:
      type: array
      items:
        description: Kraken API error
        type: string
        example: EGeneral:Invalid arguments
  securitySchemes:
    API-Key:
      type: apiKey
      description: The "API-Key" header should contain your API key.
      name: API-Key
      in: header
    API-Sign:
      type: apiKey
      description: >-
        Authenticated requests should be signed with the "API-Sign" header,
        using a signature generated with your private key, nonce, encoded
        payload, and URI path.
      name: API-Sign
      in: header

````