Exchange

Every request listed on this page requires authorization to be successfully completed.

Get available exchange directions

GET https://public.api.0xpay.app/merchants/exchange/available-directions/

You should use this endpoint before any exchange operations for following reasons:

1.Get available directions for exchange through 0xpay (tickers). 2.Get 0xpay exchange limitations (min, max). 3.Find the way how you should format your swaps (precision, step).

In response you'll get an array of two objects: target and exchange with info about available assets, limits, and amount precision.

amountStep indicates the smallest portion of asset that can be added/substracted from the exchange amount, any smaller digits will not be accepted for the exchange.

For example: if amountStep=0.001, then valid amount: 5.005, and anything containing smaller digits is not valid: 1.0005 .

[
    {
        "target": {
            "ticker": "BNB", //asset to receive
            "amountStep": "0.01000000", //exchange amount can be changed by at least 0.01 BNB
        },
        "exchange": {
            "ticker": "BUSD",//asset to spend
            "amountStep": "0.00010000", //exchange amount can be changed by at least 0.0001 BUSD 
            "max": "10000", //maximum exchange amount in BUSD
            "min": "0.00010000"//minimum exchange amount in BUSD
        }
    },
    {
        "target": {
            "ticker": "BUSD",
            "amountStep": "0.00010000"
        },
        "exchange": {
            "ticker": "BNB",
            "amountStep": "0.01000000",
            "max": "1000",
            "min": "0.01000000"
        }
    }
}

Estimate exchange

GET https://public.api.0xpay.app/merchants/exchange/estimate/

You can use this endpoint to estimate your exchange for later creation

Query Parameters

Name
Type
Description

targetTicker*

string

Asset that you want to receive to your balance. Find values using "List all supported assets" request + Fiat ticker KZT

spendTicker*

string

Asset that you want to spend from your balance. Find values using "List all supported assets" request + Fiat ticker KZT

amount*

string

amount in decimal format

side*

string

Your chosen direction, two possible values: target or spend

price

string

actual price of the pair

In response, you'll get details for your upcoming exchange:

{
    "price": { //object
        "value": "40", // price of the exchange pair
        "pair": ["UAH", "USDT"] // "Pair" is array of two "ticker" strings, values can be found in API reference

    },
    "exchange": { // detailed summary of operation
        "amount": "4030", //amount to be exchanged
        "ticker": "UAH", //ticker to spend for exchange
        "fee": "20" // transaction fee
    },
    "target": {
        "amount": "100", // amount to receive to balance
        "ticker": "USDT" // ticker to receive to balance
    },
    "spend": {
        "amount": "4020", // amount to spend, including fees
        "ticker": "UAH" // ticker to spend
    }
}

Create exchange operation

POST https://public.api.0xpay.app/merchants/exchange

Use this endpoint to create an exchange of two assets.

Status Notifications: After the Success response, 0xpay API will produce notifications according to status updates on your exchange.

Request Body

Name
Type
Description

spendTicker*

string

Ticker you want to spend (exchange) from your balance.

Find values using "List all supported assets" request + Fiat ticker UAH

amount*

string

decimal format number presented as a string

targetTicker*

string

Asset that you want to receive to your balance. Find values using "List all supported assets" request + Fiat ticker UAH

side*

string

Your chosen direction, two possible values: target or spend

fee*

string

you can specify withdrawal fees that have to be greater than the actual fee, which can be useful for better fee calculation options on your side. If not the specified –fee will be set automatically

price*

string

actual price of the pairs

localId

string

if was specified error will be thrown if not unique, can be useful on your side to avoid the issue

meta

string

metadata that you can define and catch it back later with notification

{
    "id": "123e4567-e89b-12d3-a456-426614174000" //internal ID has been assigned to the exchange
}

Last updated