Trading Guide
Overview
A trade converts between a cryptocurrency and a fiat currency in an account's balance: buying crypto with fiat, or selling crypto for fiat. Trades are always between a cryptocurrency and a fiat currency; direct exchanges between two cryptocurrencies are not supported.
Each trade is on a product, a pair written BASE-QUOTE with a hyphen: BTC-USD, ETH-USD, USDC-MXN, USDT-BRL and so on. GET /api/v2/trade-products lists the products your workspace can trade.
Every call in this guide takes either kind of API key, and both send accountId in the body. A workspace-scoped key names any account of the workspace; an account-scoped key sends its own, and naming another account answers 403. See Key types and permissions.
Trade Flow
1. Preview the trade
- Endpoint:
POST /api/v2/trade/preview, with theaccountId, theproduct, thetype(market, the only one), theside(buyorsell), thequantityand itsquantityCurrency: the fiat currency for a buy (USDto spend), the crypto for a sell (BTCto sell). - Result: the estimated rate, fees and amount the account would receive, a
previewId, andexpiresAt, when the preview lapses. Nothing is reserved or moved.
2. Execute the trade
- Endpoint:
POST /api/v2/trade/execute, with the same order fields and, optionally, thepreviewId. - Result: the trade's
transactionId. The amount being spent is held from the balance while the trade runs.
Sending the previewId asks for the preview's rate and fees, but does not guarantee them: the final rate can still move with the market. The account must have the balance for the trade, and a frozen account cannot trade.
3. Follow the trade
- Webhooks:
trade_transaction_createdwhen the trade is accepted, thentrade_transaction_status_updatedwhen it settles (success) or fails (failed). See Trade Webhooks. - Result: on
success, the converted amount is credited to the account's balance in the currency it bought.
4. Review past trades
- Endpoint:
GET /api/v2/transactionswithtransactionType=trade, orGET /api/v2/transactions/{transactionId}for one trade. - Result: each trade with its rate, fee, quantities and status history (
tradeTransactionDetails).
Key Terminology
- Trade: an operation that converts between a cryptocurrency and a fiat currency.
- Product: the pair a trade is on, such as
BTC-USD: the crypto first, the fiat second. - Fiat: a government currency held in a bank account:
USD,MXN,ARS,COP,BRLorNGN, as your workspace offers them. - Exchange rate: the rate at which the crypto converts to the fiat currency.
Important Notes
- A preview has a limited validity (
expiresAt). Executing with itspreviewIdasks for its terms, but the market can still move the final rate. - Once a trade has settled, it cannot be reversed.
Support and Resources
If you need assistance or have any questions, our support team is here to help. You can contact our support team at support@blockwyre.com.
Stay Updated
Stay up-to-date with the latest news, updates, and features from BlockWyre by following us on social media:
- Instagram: BlockWyre Instagram
- Twitter: BlockWyre Twitter
- Facebook: BlockWyre Facebook
- LinkedIn: BlockWyre LinkedIn
We are excited to have you on board and look forward to seeing how you leverage BlockWyre's powerful tools to enhance your financial operations. Happy integrating!