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

# Get Order Book (L2)

> Get current L2 aggregated order book



## OpenAPI

````yaml /api-specs/public-rest-unified.json get /stats/api/v1/order_book_l2
openapi: 3.1.0
info:
  title: DerivaDEX API Documentation
  version: '1.0'
  description: ''
servers:
  - url: https://testnet.derivadex.io
    description: DerivaDEX testnet
security: []
tags:
  - name: Venue-Wide Tables
    description: These APIs expose venue-wide public tables and reference data.
    x-source-api: Public REST API
  - name: System
    description: These APIs return system info.
    x-source-api: Public REST API
  - name: Trade
    description: These APIs provide data for a particular trader.
    x-source-api: Public REST API
  - name: Market
    description: These APIs return key high level metrics for markets.
    x-source-api: Public REST API
  - name: Trade
    description: These APIs provide data for a particular trader.
    x-source-api: Public Exchange REST API
  - name: Market
    description: These APIs return key high level metrics for markets.
    x-source-api: Public Exchange REST API
  - name: System
    description: These APIs return system info.
    x-source-api: Public Exchange REST API
paths:
  /stats/api/v1/order_book_l2:
    get:
      tags:
        - Market
      summary: Get Order Book (L2)
      description: Get current L2 aggregated order book
      parameters:
        - in: query
          name: symbol
          schema:
            type: string
          description: The symbol
          example: ETHP
        - name: depth
          in: query
          schema:
            type: integer
          example: 4
          description: The best N bids and asks to return, where N = depth
        - in: query
          name: side
          schema:
            type: integer
            enum:
              - 0
              - 1
          description: |
            The side of the order. Values include:
              0: Bid,
              1: Ask
          example: 0
        - in: query
          name: priceAggregation
          schema:
            type: number
            enum:
              - 0.1
              - 1
              - 10
              - 100
          description: >
            The price aggregation to use for the L2 orderbook. Valid values for
            each symbol include:
              ETHP: 0.1, 1, 10
              BTCP: 1, 10, 100
      responses:
        '200':
          description: Order Book L2 data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderBookL2APISuccessResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsAPIErrorResponse'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsAPIErrorResponse'
components:
  schemas:
    OrderBookL2APISuccessResponse:
      type: object
      additionalProperties: false
      properties:
        value:
          type: array
          items:
            type: object
            properties:
              symbol:
                type: string
                description: The symbol of the asset for this order aggregation.
                examples:
                  - ETHP
              side:
                type: number
                description: >-
                  The side of the order aggregation. Values include:  0: Bid, 
                  1: Ask
                examples:
                  - 0
                  - 1
              amount:
                type: string
                description: The order amount currently left on this aggregation level.
                examples:
                  - '0.9'
              price:
                type: string
                description: The price level of the aggregation.
                examples:
                  - '596'
            required:
              - symbol
              - side
              - amount
              - price
            additionalProperties: false
            description: An aggregated orderbook level part of an L2.
            examples:
              - symbol: ETHP
                amount: '0.1'
                price: 1000
                side: 0
          description: The value of the response
        success:
          type: boolean
          const: true
          description: Whether the request was successful
        timestamp:
          type: number
          description: The timestamp of the response
          examples:
            - 1673031089
      required:
        - success
        - timestamp
        - value
      description: Successful response for the Order Book L2 API
    StatsAPIErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          const: false
        errorMsg:
          anyOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: false
      required:
        - success
      additionalProperties: false

````