# Order Book

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/order-book/{instrument_code}:
    get:
      summary: Order Book
      deprecated: false
      description: >-
        Get the specified instrument's order book At most the top 16 price
        levels per side are returned. When `depth` is supplied it takes
        precedence over `level`; `level` is still validated.
      tags:
        - One Trading Public REST API/Public
        - public
      parameters:
        - name: instrument_code
          in: path
          description: The instrument code, e.g. `BTC_USDC`.
          required: true
          example: BTC_USDC
          schema:
            type: string
        - name: level
          in: query
          description: |-
            Deprecated; use `depth`.
            Level 1 = best bid and ask
            Level 2 and Level 3 = top 16 price levels per side
          required: false
          example: '1'
          schema:
            type: string
            enum:
              - '1'
              - '2'
              - '3'
            x-apidog-enum:
              - value: '1'
                name: ''
                description: Best bid and ask
              - value: '2'
                name: ''
                description: Top 16 price levels (same as 3)
              - value: '3'
                name: ''
                description: Top 16 price levels
            deprecated: true
            default: '3'
          deprecated: true
        - name: depth
          in: query
          description: >-
            The number of price levels per side to return (maximum 16). Depth of
            1 will return top of book.
          required: false
          example: '16'
          schema:
            type: string
            enum:
              - '1'
              - '2'
              - '4'
              - '8'
              - '16'
            x-apidog-enum:
              - value: '1'
                name: ''
                description: ''
              - value: '2'
                name: ''
                description: ''
              - value: '4'
                name: ''
                description: ''
              - value: '8'
                name: ''
                description: ''
              - value: '16'
                name: ''
                description: ''
            default: '16'
      responses:
        '200':
          x-apidog-name: Success
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  asks:
                    type: array
                    items:
                      type: object
                      properties:
                        price:
                          type: string
                        amount:
                          type: string
                      x-apidog-orders:
                        - price
                        - amount
                      required:
                        - price
                        - amount
                      x-apidog-ignore-properties: []
                    description: Ask price levels, best (lowest) first.
                  bids:
                    type: array
                    items:
                      type: object
                      properties:
                        price:
                          type: string
                        amount:
                          type: string
                      x-apidog-orders:
                        - price
                        - amount
                      required:
                        - price
                        - amount
                      x-apidog-ignore-properties: []
                    description: Bid price levels, best (highest) first.
                  instrument_code:
                    type: string
                    description: The instrument code.
                  time:
                    type: integer
                    description: >-
                      Nanosecond timestamp of the order-book snapshot. The value
                      exceeds 2^53, so JSON parsers that use IEEE-754 doubles
                      will lose precision in the last digits.
                  unum_bids:
                    type: integer
                    description: Count of bids in the full book.
                  unum_asks:
                    type: integer
                    description: Count of asks in the full book.
                x-apidog-orders:
                  - asks
                  - bids
                  - instrument_code
                  - time
                  - unum_bids
                  - unum_asks
                required:
                  - asks
                  - bids
                  - instrument_code
                  - time
                x-apidog-ignore-properties: []
              examples:
                '1':
                  summary: Success
                  value:
                    instrument_code: BTC_USDC
                    time: 1730900885466242800
                    asks:
                      - price: '100000'
                        amount: '6'
                    bids:
                      - price: '10000'
                        amount: '6'
                    unum_bids: 1
                    unum_asks: 1
          headers: {}
        '400':
          x-apidog-name: Bad Request
          description: >-
            Invalid request. Possible codes: `INVALID_INSTRUMENT_CODE` (unknown
            instrument), `INVALID_DEPTH`, `INVALID_LEVEL`.
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                '2':
                  summary: Invalid instrument code
                  value:
                    error: INVALID_INSTRUMENT_CODE
                '3':
                  summary: Invalid depth
                  value:
                    error: INVALID_DEPTH
                '4':
                  summary: Invalid level
                  value:
                    error: INVALID_LEVEL
          headers: {}
        '500':
          x-apidog-name: Server Error
          description: Unexpected server error. `error` is a human-readable message.
          content:
            application/json:
              schema: *ref_0
              example:
                error: Error fetching order book snapshot for BTC_USDC
          headers: {}
      security: []
      x-apidog-folder: One Trading Public REST API/Public
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/349694/apis/api-3612085-run
components:
  schemas:
    ErrorResponse:
      type: object
      description: >-
        Error body. `error` is a machine-readable code (e.g.
        `INVALID_INSTRUMENT_CODE`) on most endpoints; a few older endpoints
        return a human-readable message in `error` instead and omit
        `error_message`.
      properties:
        error:
          type: string
          description: Error code (or, on older endpoints, a human-readable message).
        error_message:
          type: string
          description: >-
            Human-readable detail. Present on endpoints that return an error
            code in `error`.
      required:
        - error
      x-apidog-orders:
        - error
        - error_message
      x-apidog-folder: ''
      x-apidog-ignore-properties: []
  securitySchemes:
    bearerAuth:
      type: bearer
      scheme: bearer
      description: >-
        API key issued to the account holder, sent as `Authorization: Bearer
        <token>`. The key must hold the `SUBACCOUNT_TRANSFER` scope.
    bearer:
      type: bearer
      scheme: bearer
servers:
  - url: https://api.onetrading.com/fast
    description: Production Env
security: []

```