Blockchain.com Trading API

Post orders and get information about historical trades

OpenAPI Specification

blockchain.com-trading-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Blockchain.com Exchange REST Trading API
  description: '## Introduction

    Welcome to Blockchain.com''s Exchange API and developer documentation. \

    These documents detail and give examples of various functionality offered by the API such as receiving real time market data, requesting balance information and performing trades.

    ## To Get Started

    Create or log into your existing Blockchain.com Exchange account \

    Select API from the drop down menu \

    Fill out form and click “Create New API Key Now” \

    Once generated you can view your keys under API Settings. \

    Please be aware that the API key can only be used once it was verified via email.


    The API key must be set via the \

    `X-API-Token`\

    header.


    The base URL to be used for all calls is \

    `https://api.blockchain.com/v3/exchange`


    Autogenerated clients for this API can be found [here](https://github.com/blockchain/lib-exchange-client).

    '
  version: 1.0.0
servers:
- url: https://api.blockchain.com/v3/exchange
security:
- ApiKeyAuth: []
tags:
- name: trading
  description: Post orders and get information about historical trades
paths:
  /fees:
    get:
      summary: Get current fee level
      description: ''
      operationId: getFees
      tags:
      - trading
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fees'
  /orders:
    get:
      summary: Get a list orders
      description: Returns live and historic orders, defaulting to live orders. Returns at most 100 results, use timestamp to paginate for further results
      operationId: getOrders
      tags:
      - trading
      parameters:
      - $ref: '#/components/parameters/symbolFilter'
      - $ref: '#/components/parameters/timeFromFilter'
      - $ref: '#/components/parameters/timeToFilter'
      - $ref: '#/components/parameters/orderStatusFilter'
      - $ref: '#/components/parameters/limitFilter'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/OrderSummary'
    post:
      summary: Add an order
      description: ''
      operationId: createOrder
      tags:
      - trading
      requestBody:
        description: Trade
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BaseOrder'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
    delete:
      summary: Delete all open orders (of a symbol, if specified)
      description: ''
      operationId: deleteAllOrders
      tags:
      - trading
      parameters:
      - in: query
        name: symbol
        required: false
        schema:
          $ref: '#/components/schemas/symbol'
      responses:
        '200':
          description: Success
  /orders/{orderId}:
    get:
      summary: Get a specific order
      description: ''
      operationId: getOrderById
      tags:
      - trading
      parameters:
      - $ref: '#/components/parameters/orderIdParam'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderSummary'
        '404':
          description: Not found
    delete:
      summary: Cancel a trade
      description: ''
      operationId: deleteOrder
      tags:
      - trading
      parameters:
      - $ref: '#/components/parameters/orderIdParam'
      responses:
        '200':
          description: Success
  /trades:
    get:
      summary: Get a list of filled orders
      description: Returns filled orders, including partial fills. Returns at most 100 results, use timestamp to paginate for further results
      operationId: getFills
      tags:
      - trading
      parameters:
      - $ref: '#/components/parameters/symbolFilter'
      - $ref: '#/components/parameters/timeFromFilter'
      - $ref: '#/components/parameters/timeToFilter'
      - $ref: '#/components/parameters/limitFilter'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/OrderSummary'
components:
  schemas:
    minQty:
      type: number
      format: double
      description: The minimum quantity required for an IOC fill
      example: '10.0'
    ExchangeOrderId:
      type: integer
      format: int64
      description: The unique order id assigned by the exchange
      example: '11111111'
    ordType:
      type: string
      title: Order type
      enum:
      - MARKET
      - LIMIT
      - STOP
      - STOPLIMIT
    side:
      type: string
      enum:
      - BUY
      - SELL
      description: '"buy" for Buy, "sell" for Sell'
      example: BUY
    orderQty:
      type: number
      format: double
      description: The order size in the terms of the base currency
      example: '10.23'
    ClientOrderId:
      type: string
      maxLength: 20
      pattern: ^[a-zA-Z0-9]{1,20}$
      description: Reference field provided by client. Cannot exceed 20 characters, only alphanumeric characters are allowed.
      example: ABC
    OrderSummary:
      type: object
      required:
      - clOrdId
      - ordType
      - ordStatus
      - side
      - symbol
      properties:
        exOrdId:
          $ref: '#/components/schemas/ExchangeOrderId'
        clOrdId:
          $ref: '#/components/schemas/ClientOrderId'
        ordType:
          $ref: '#/components/schemas/ordType'
        ordStatus:
          $ref: '#/components/schemas/OrderStatus'
        side:
          $ref: '#/components/schemas/side'
        price:
          $ref: '#/components/schemas/price'
        text:
          type: string
          description: The reason for rejecting the order, if applicable
        symbol:
          $ref: '#/components/schemas/symbol'
        lastShares:
          type: number
          format: double
          description: The executed quantity for the order's last fill
          example: '0.5678'
        lastPx:
          type: number
          format: double
          description: The executed price for the last fill
          example: '3500.12'
        leavesQty:
          type: number
          format: double
          description: For Open and Partially Filled orders this is the remaining quantity open for execution. For Canceled and Expired orders this is the quantity than was still open before cancellation/expiration. For Rejected order this is equal to orderQty. For other states this is always zero.
          example: '10.0'
        cumQty:
          type: number
          format: double
          description: The quantity of the order which has been filled
          example: '0.123345'
        avgPx:
          type: number
          format: double
          description: Calculated the Volume Weighted Average Price of all fills for this order
          example: '345.33'
        timestamp:
          $ref: '#/components/schemas/TimestampEpoch'
    TimestampEpoch:
      type: integer
      format: int64
      description: Time in ms since 01/01/1970 (epoch)
      example: '1592830770594'
    TimeInForce:
      type: string
      enum:
      - GTC
      - IOC
      - FOK
      - GTD
      description: '"GTC" for Good Till Cancel, "IOC" for Immediate or Cancel, "FOK" for Fill or Kill, "GTD" Good Till Date'
      example: GTC
    expireDate:
      type: integer
      minimum: 20200101
      maximum: 20501231
      description: expiry date in the format YYYYMMDD
      example: '20200103'
    BaseOrder:
      type: object
      required:
      - clOrdId
      - ordType
      - symbol
      - side
      - orderQty
      properties:
        clOrdId:
          $ref: '#/components/schemas/ClientOrderId'
        ordType:
          $ref: '#/components/schemas/ordType'
        symbol:
          $ref: '#/components/schemas/symbol'
        side:
          $ref: '#/components/schemas/side'
        orderQty:
          $ref: '#/components/schemas/orderQty'
        timeInForce:
          $ref: '#/components/schemas/TimeInForce'
        price:
          $ref: '#/components/schemas/price'
        expireDate:
          $ref: '#/components/schemas/expireDate'
        minQty:
          $ref: '#/components/schemas/minQty'
        stopPx:
          $ref: '#/components/schemas/price'
      example:
        clOrdId: '123456'
        ordType: LIMIT
        symbol: BTC-USD
        side: BUY
        orderQty: '0.1'
        price: '100'
    Fees:
      type: object
      required:
      - makerRate
      - takerRate
      - volumeInUSD
      properties:
        makerRate:
          type: number
          format: double
          example: '0.0014'
          description: ''
        takerRate:
          type: number
          format: double
          example: '0.0024'
          description: ''
        volumeInUSD:
          type: number
          format: double
          example: '1500.00'
          description: ''
    price:
      type: number
      format: double
      description: The limit price for the order
      example: 0.12345
    symbol:
      type: string
      pattern: ^[A-Z]{3,5}-[A-Z]{3,5}$
      description: Blockchain symbol identifier
      example: BTC-USD
    OrderStatus:
      type: string
      example: FILLED
      enum:
      - OPEN
      - REJECTED
      - CANCELED
      - FILLED
      - PART_FILLED
      - EXPIRED
  parameters:
    timeToFilter:
      name: to
      in: query
      description: Epoch timestamp in ms
      required: false
      schema:
        $ref: '#/components/schemas/TimestampEpoch'
    limitFilter:
      name: limit
      in: query
      description: 'Maximum amount of results to return in a single call. If omitted, 100 results are returned by default. '
      required: false
      schema:
        type: integer
        format: int32
        minimum: 1
        maximum: 1000
        example: 100
    timeFromFilter:
      name: from
      in: query
      description: Epoch timestamp in ms
      required: false
      schema:
        $ref: '#/components/schemas/TimestampEpoch'
    orderIdParam:
      name: orderId
      in: path
      description: Order ID
      required: true
      schema:
        $ref: '#/components/schemas/ExchangeOrderId'
    symbolFilter:
      name: symbol
      in: query
      description: Only return results for this symbol
      required: false
      schema:
        $ref: '#/components/schemas/symbol'
    orderStatusFilter:
      name: status
      in: query
      description: Order Status
      required: false
      schema:
        $ref: '#/components/schemas/OrderStatus'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Token