Skip to content

API of Trades

Introduction

Trades are the fiat side of the exchange engine. Same endpoints, same flow — just with a fiat currency on one side (cash in or cash out) instead of two crypto assets. Use it to let users buy crypto with USD/EUR/AED or cash out crypto to a bank account.

All endpoints below require a developer api-key header. Contact us to get one.

http
api-key: YOUR_P3P_API_KEY

How fiat works

A trade is just an exchange where one side is a fiat asset instead of a chain token. Set asset_from (or asset_to) to a fiat key like "usd", "eur", "aed" — and skip the matching chain_* / token_* fields on that side. The request type automatically switches to "cash".

Endpoints


1. Get Fiats

GET /fiats api-key required

Returns every fiat currency currently supported.

bash
curl https://api.p3p.xyz/fiats \
  -H "api-key: YOUR_P3P_API_KEY"
json
{
  "usd": { "key": "usd", "name": "US Dollar",         "enabled": true },
  "eur": { "key": "eur", "name": "Euro",              "enabled": true },
  "aed": { "key": "aed", "name": "UAE Dirham",        "enabled": true }
}

2. Get Rates

GET /rates api-key required

Same /rates endpoint as Exchanges — returns reference rates for both crypto and fiat assets.

bash
curl https://api.p3p.xyz/rates \
  -H "api-key: YOUR_P3P_API_KEY"

3. Quote Trade Rate

POST /exchange/rate api-key required

Same endpoint as crypto exchanges. Put a fiat key in asset_from or asset_to to switch into trade mode.

Fiat → Crypto

User wants to buy crypto with cash.

bash
curl -X POST https://api.p3p.xyz/exchange/rate \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_P3P_API_KEY" \
  -d '{
    "asset_from": "usd",
    "amount_from": "100",
    "chain_to": "eth",
    "token_to": "usdt"
  }'

Crypto → Fiat

User wants to cash out crypto.

bash
curl -X POST https://api.p3p.xyz/exchange/rate \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_P3P_API_KEY" \
  -d '{
    "chain_from": "eth",
    "token_from": "usdt",
    "amount_from": "100",
    "asset_to": "aed"
  }'

4. Create Trade

POST /exchange/create api-key required

Same endpoint as crypto exchanges. Lock the trade rate and receive payment instructions for the cash leg, or a deposit address for the crypto leg.

Fiat → Crypto

bash
curl -X POST https://api.p3p.xyz/exchange/create \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_P3P_API_KEY" \
  -d '{
    "asset_from": "usd",
    "amount_from": "100",
    "chain_to": "eth", "token_to": "usdt",
    "wallet_to": "0xRecipient...address"
  }'

Crypto → Fiat

bash
curl -X POST https://api.p3p.xyz/exchange/create \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_P3P_API_KEY" \
  -d '{
    "chain_from": "eth", "token_from": "usdt", "amount_from": "100",
    "asset_to": "aed",
    "wallet_to": "iban:AE07..."
  }'

Track the trade with the same Check Exchange Status endpoint.