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

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

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

Last updated