Skip to content

Convert

POSThttps://connect.cabital.com/api/v1/accounts/{account_id}/conversions

User Account Status

  • Linked
  • KYC Pass

Request Path Parameters

Parameter Required Description
account_id Yes Customer account ID provided by Cabital.

Request Body Parameters

Content Type: application/json

Parameter Required Type Description
pair Yes string Trading pairs, format: buy_currency-sell_currency.
e.g. USDT-EUR presents the quote information of Buy USDT and Sell EUR
quote_id Yes string Quote ID, retrieve from request Quote API by parameter pair.
quote Yes string Quote value, retrieve from request Quote API by parameter pair.
buy_amount Yes string Buy amount, should follow the precision of buy currency.
sell_amount Yes string Sell amount, should follow the precision of sell currency.
major_ccy Yes string The currency customers enter on conversion UI, the system will check the corresponding amount meet the restriction.

What affect the restriction of conversion?

The restriction follows the partner's configuration of the currency (config.conversion: min and max)

Calculation of sell amount or buy amount

major_ccypair USDT-EUR EUR-USDT
USDT Buy USDT Sell EUR
Buy amount multiply by the quote to calculate the sell amount.
buy_amount*quote = sell_amount
Sell USDT Buy EUR
Sell amount divide by the quote to calculate the buy amount
sell_amount*(1/quote) = buy_amount
EUR Sell EUR Buy USDT
Sell amount divide by the quote to calculate the buy amount
sell_amount*(1/quote) = buy_amount
Buy EUR Sell USDT
Buy amount multiplied by the quote to calculate the sell amount.
buy_amount*quote = sell_amount

Response Parameters

Parameter Type Description
transaction_id string Transaction ID
status string Transaction status

Example

Request Data (Buy USDT Sell EUR)

The customer wants to buy 100 amount of USDT by selling EUR

  1. Use pair USDT-EUR to get quote by Retrieve a quote by trading pair API

    curl "http://connect.cabital.com/api/v1/quotes/USDT-EUR"
    
    {
        "quote": "1.011129",
        "valid_until": 1662101436,
        "quote_id": "20220902065031:USDT-EUR:Customer",
        "valid_interval": 5,
        "reversed_quote": "1.0050453275"
    }
    

  2. Calculate the amount to sell: 100*1.011129 = 101.1129, use this as the value of parameter sell_amount

    curl -X POST "http://connect.cabital.com/api/v1/accounts/6d92e7b4-715c-4ce3-a028-19f1c8c9fa6c/conversions" \
    -d {
      "quote_id": "20220902065031:USDT-EUR:Customer",
      "quote": "1.011129",
      "pair": "USDT-EUR",
      "buy_amount": "100",
      "sell_amount": "101.1129",
      "major_ccy": "USDT"
    }
    

Request Data (Sell EUR Buy USDT)

The customer wants to sell 100 amount of EUR by buying USDT

  1. Use pair USDT-EUR to get quote by Retrieve a quote by trading pair API

    curl "http://connect.cabital.com/api/v1/quotes/USDT-EUR"
    
    {
        "quote": "1.011129",
        "valid_until": 1662101436,
        "quote_id": "20220902065031:USDT-EUR:Customer",
        "valid_interval": 5,
        "reversed_quote": "1.0050453275"
    }
    

  2. Calculate the amount to buy: 100*(1/1.011129) = 98.89934914, use this as the value of parameter buy_amount

    curl -X POST "http://connect.cabital.com/api/v1/accounts/6d92e7b4-715c-4ce3-a028-19f1c8c9fa6c/conversions" \
    -d {
      "quote_id": "20220902065031:USDT-EUR:Customer",
      "quote": "1.011129",
      "pair": "USDT-EUR",
      "buy_amount": "98.89934914",
      "sell_amount": "100",
      "major_ccy": "EUR"
    }
    

Request Data (Sell USDT Buy EUR)

The customer wants to sell 100 amount of USDT by buying EUR

  1. Use pair EUR-USDT to get quote by Retrieve a quote by trading pair API

    curl "http://connect.cabital.com/api/v1/quotes/EUR-USDT"
    
    {
        "quote": "1.0050453275",
        "valid_until": 1662101436,
        "quote_id": "20220902065031:USDT-EUR:Customer",
        "valid_interval": 5,
        "reversed_quote": "1.011129"
    }
    

  2. Calculate the amount to buy: 100*(1/1.0050453275) = 99.498, use this as the value of parameter buy_amount

    curl -X POST "http://connect.cabital.com/api/v1/accounts/6d92e7b4-715c-4ce3-a028-19f1c8c9fa6c/conversions" \
    -d {
      "quote_id": "20220902065031:USDT-EUR:Customer",
      "quote": "1.0050453275",
      "pair": "EUR-USDT",
      "buy_amount": "99.498",
      "sell_amount": "100",
      "major_ccy": "USDT"
    }
    

Request Data (Buy EUR Sell USDT)

The customer wants to buy 100 amount of EUR by selling USDT

  1. Use pair EUR-USDT to get quote by Retrieve a quote by trading pair API

    curl "http://connect.cabital.com/api/v1/quotes/EUR-USDT"
    
    {
        "quote": "1.0050453275",
        "valid_until": 1662101436,
        "quote_id": "20220902065031:USDT-EUR:Customer",
        "valid_interval": 5,
        "reversed_quote": "1.011129"
    }
    

  2. Calculate the amount to sell: 100*1.0050453275 = 100.50453275, use this as the value of parameter sell_amount

    curl -X POST "http://connect.cabital.com/api/v1/accounts/6d92e7b4-715c-4ce3-a028-19f1c8c9fa6c/conversions" \
    -d {
      "quote_id": "20220902065031:USDT-EUR:Customer",
      "quote": "1.0050453275",
      "pair": "EUR-USDT",
      "buy_amount": "100",
      "sell_amount": "100.50453275",
      "major_ccy": "USDT"
    }