HitBTC Margin Account API

The Margin Account API from HitBTC — 2 operation(s) for margin account.

Operations 5

GET /margin/account Get all margin accounts #
DELETE /margin/account Close all margin positions #
GET /margin/account/{symbol} Get margin account details by symbol #
PUT /margin/account/{symbol} Update margin account by symbol #
DELETE /margin/account/{symbol} Close margin account by symbol #

Documentation

Specifications

Schemas & Data

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/hitbtc:hitbtc-margin-account-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

hitbtc-margin-account-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Hitbtc Margin Account API
  version: ''
  description: 'Operations tagged Margin Account across 2 of this provider''s published API definitions: hitbtc-api-v2-spec.yaml, hitbtc-v2-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: /api/2
- url: https://api.hitbtc.com/api/2
  description: Production; the served spec declares the relative server /api/2 and the docs at api.hitbtc.com name this host
tags:
- name: Margin Account
paths:
  /margin/account:
    get:
      tags:
      - Margin Account
      summary: Get all margin accounts
      description: 'Returns a list of margin account details.


        **Permission:** *TradingRead*'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/trading_UserMarginAccountInfo'
        '401':
          $ref: '#/components/responses/trading_UnauthorizedError'
        '403':
          $ref: '#/components/responses/trading_ForbiddenError'
        '500':
          $ref: '#/components/responses/trading_InternalServerError'
        default:
          $ref: '#/components/responses/trading_Error'
      security:
      - trading_BasicAuth: []
      - trading_BearerAuth: []
      operationId: getMarginAccount
      x-operation-id-source: derived
    delete:
      tags:
      - Margin Account
      summary: Close all margin positions
      description: 'It will completely free up any balance reserved for margin purposes. All open positions will be closed at the market price.


        Returns a list of margin accounts with closed positions.


        **Permission:** *TradingTrade*'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/trading_UserMarginAccountInfo'
        '401':
          $ref: '#/components/responses/trading_UnauthorizedError'
        '403':
          $ref: '#/components/responses/trading_ForbiddenError'
        '500':
          $ref: '#/components/responses/trading_InternalServerError'
        default:
          $ref: '#/components/responses/trading_Error'
      security:
      - trading_BasicAuth: []
      - trading_BearerAuth: []
      operationId: deleteMarginAccount
      x-operation-id-source: derived
    servers:
    - url: /api/2
  /margin/account/{symbol}:
    parameters:
    - $ref: '#/components/parameters/trading_symbolPath'
    get:
      tags:
      - Margin Account
      summary: Get margin account details by symbol
      description: '**Permission:** *TradingRead*'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/trading_UserMarginAccountInfo'
        '400':
          $ref: '#/components/responses/trading_BadRequestError'
        '401':
          $ref: '#/components/responses/trading_UnauthorizedError'
        '403':
          $ref: '#/components/responses/trading_ForbiddenError'
        '500':
          $ref: '#/components/responses/trading_InternalServerError'
        default:
          $ref: '#/components/responses/trading_Error'
      security:
      - trading_BasicAuth: []
      - trading_BearerAuth: []
      operationId: getMarginAccountBySymbol
      x-operation-id-source: derived
    put:
      tags:
      - Margin Account
      summary: Update margin account by symbol
      description: 'Returns updated margin account details.


        **Permission:** *TradingTrade*'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/trading_PositionChangeRequest'
      responses:
        '200':
          description: OK
          content:
            application/x-www-form-urlencoded:
              schema:
                $ref: '#/components/schemas/trading_UserMarginAccountInfo'
        '400':
          $ref: '#/components/responses/trading_BadRequestError'
        '401':
          $ref: '#/components/responses/trading_UnauthorizedError'
        '403':
          $ref: '#/components/responses/trading_ForbiddenError'
        '500':
          $ref: '#/components/responses/trading_InternalServerError'
        default:
          $ref: '#/components/responses/trading_Error'
      security:
      - trading_BasicAuth: []
      - trading_BearerAuth: []
      operationId: putMarginAccountBySymbol
      x-operation-id-source: derived
    delete:
      tags:
      - Margin Account
      summary: Close margin account by symbol
      description: 'It will completely free up any balance reserved for margin purposes. All open positions will be closed at the market price.


        Returns a list of the closed margin accounts.


        **Permission:** *TradingTrade*'
      parameters:
      - name: price
        in: query
        schema:
          type: number
          minimum: 0
        description: Market price to close the position.
      - name: strictValidate
        in: query
        schema:
          type: boolean
        description: Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/trading_UserMarginAccountInfo'
        '400':
          $ref: '#/components/responses/trading_BadRequestError'
        '401':
          $ref: '#/components/responses/trading_UnauthorizedError'
        '403':
          $ref: '#/components/responses/trading_ForbiddenError'
        '500':
          $ref: '#/components/responses/trading_InternalServerError'
        default:
          $ref: '#/components/responses/trading_Error'
      security:
      - trading_BasicAuth: []
      - trading_BearerAuth: []
      operationId: deleteMarginAccountBySymbol
      x-operation-id-source: derived
    servers:
    - url: /api/2
components:
  schemas:
    trading_Error:
      required:
      - error
      type: object
      properties:
        error:
          required:
          - code
          - message
          type: object
          properties:
            code:
              type: integer
              format: int
            message:
              type: string
            description:
              type: string
    trading_UserPositionInfo:
      required:
      - id
      - symbol
      - quantity
      - pnl
      - priceEntry
      - priceMarginCall
      - priceLiquidation
      - createdAt
      - updatedAt
      type: object
      properties:
        id:
          type: integer
          format: uint64
          description: Position identifier.
        symbol:
          type: string
          description: Symbol code.
        quantity:
          type: string
          description: Position quantity.
        pnl:
          type: string
          description: Unrealized profit and loss.
        feeCumulative:
          type: string
          description: "Total amount of fees paid throughout the position lifetime until it\n is closed.\n\nFormat: Decimal\n\nValues: `0` if a new position created\n\n⚠️ This value does zero out after the position closes  and does not\n when it flips.\n"
        priceEntry:
          type: string
          description: Average weighted price of position's open orders.
        priceMarginCall:
          type: string
          description: Margin call price.
        priceLiquidation:
          type: string
          description: Liquidation Price.
        createdAt:
          type: string
          format: date-time
          description: Position creation date and time.
        updatedAt:
          type: string
          format: date-time
          description: Position last update date and time.
    trading_UserMarginAccountInfo:
      required:
      - symbol
      - leverage
      - marginBalance
      - marginBalanceOrders
      - marginBalanceRequired
      - createdAt
      - updatedAt
      type: object
      properties:
        symbol:
          type: string
          description: Trading symbol, where base currency is the currency of funds reserved on the trading account for positions and quote currency is the currency of funds reserved on a margin account (e.g., "BTCUSDT").
        leverage:
          type: string
          description: Margin leverage. The ratio of the trader's own funds to funds borrowed from the platform.
        marginBalance:
          type: string
          description: The total value of funds reserved for margin.
        marginBalanceOrders:
          type: string
          description: The value reserved for margin orders.
        marginBalanceRequired:
          type: string
          description: The value reserved for margin position close.
        createdAt:
          type: string
          format: date-time
          description: Account creation date and time.
        updatedAt:
          type: string
          format: date-time
          description: Account last update date and time.
        position:
          $ref: '#/components/schemas/trading_UserPositionInfo'
    trading_PositionChangeRequest:
      type: object
      properties:
        marginBalance:
          type: number
          minimum: 0
          description: The total value of funds reserved for margin. Setting `"marginBalance"` to zero will close the margin account.
        strictValidate:
          type: boolean
          description: Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step.
  responses:
    trading_ForbiddenError:
      description: Action is forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/trading_Error'
    trading_InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/trading_Error'
    trading_Error:
      description: ''
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/trading_Error'
    trading_BadRequestError:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/trading_Error'
    trading_UnauthorizedError:
      description: Authorization is required or has been failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/trading_Error'
  parameters:
    trading_symbolPath:
      name: symbol
      in: path
      required: true
      schema:
        type: string
      description: Symbol code.
  securitySchemes:
    wallet_BasicAuth:
      type: http
      description: You should use public API key as username and secret API key as password to authorize.
      scheme: basic
    wallet_BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    trading_BasicAuth:
      type: http
      description: You should use public API key as username and secret API key as password to authorize.
      scheme: basic
    trading_BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
x-refined-from:
- hitbtc-api-v2-spec.yaml
- hitbtc-v2-openapi.yml