What You’ll Achieve:
- Understand the specific quote requirements for crypto conversions.
- Generate a conversion quote.
- Execute the crypto-to-crypto conversion transfer.
- Confirm the status of the conversation.
Prerequisites
Before you begin, ensure you have:- A Busha Business Account and Secret API Key (from the Quick Start Tutorial)
- An understanding of the API Environments (Sandbox vs. Production) and their respective base URLs (from the Make Your First Request Guide).
- A conceptual understanding of Quotes (from the Understanding Quotes Overview).
- Familiarity with creating basic quotes (from the How to Create Your First Quote Guide).
For conversion requests involving a customer, the
X-BU-PROFILE-ID field
should be included in the request header, and its value should be set to the
customer ID for whom the request is performed on their behalf.How to Convert Crypto to Crypto
1
Create a Conversion Quote
The first step in any conversion is to create a Quote. This specifies the Expected Quote ResponseA successful response will return a Quote object containing the
source_currency (what you’re converting from) and target_currency (what you’re converting to). You must provide either the source_amount or the target_amount, but not both.To create a conversion quote:- Open your terminal or command prompt.
- Construct a
POSTrequest to the/v1/quotesendpoint. - Specify the
source_currency,target_currency, and eithersource_amount(as shown below) ortarget_amount. Make sure to set the type to “convert”. - Replace
YOUR_BASE_URLwith your chosen environment’s URL,YOUR_SECRET_TOKENwith your actual key, andBUS_YOK8tp5Zga01qOKEsqp07with your actualX-BU-PROFILE-ID.
id, calculated target_amount (if you provided source_amount), the rate for the conversion, and its expires_at timestamp. Note the id of this quote (e.g., QUO_Nm2EBRxmuHGdTyGnVNDUt), as you’ll need it for the next step.2
Create the Conversion Transfer
Once you have a valid Quote ID, you can proceed to execute the conversion by creating a transfer. This action consumes the quote and initiates the actual asset exchange.To create the conversion transfer:Expected Transfer ResponseA successful response indicates that the transfer has been initiated. For conversions, the transaction is typically processed very quickly, often immediately. The response will include a
- Use the
POSTrequest below to the/v1/transfersendpoint. - Include the
quote_idobtained from Step 1 in the request body. - Replace
YOUR_BASE_URLandYOUR_SECRET_TOKENwith your actual details.
id (e.g., TRF_oBoehqd2KVt1wcadB8wz5) and the initial status of the transfer (likely pending or completed almost instantly).3
Confirm Transfer
Although conversion transfers are usually processed immediately, it’s good practice to confirm their final status. You can do this by retrieving the transfer details using its ID.To confirm the transfer status:Expected Statuses
- Use the
GETrequest below to the/v1/transfers/{id}endpoint. - Replace
{id}with the actualtransfer_idyou received in Step 2. - Replace
YOUR_BASE_URLandYOUR_SECRET_TOKENwith your actual details.
- completed: The conversion was successful, and your
target_currencybalance has been updated. - failed: The conversion failed (e.g., insufficient balance, quote expired before execution).
- pending: (Less common for conversions, but possible briefly) The transfer is still being processed.
A trade is a type of conversion that represents a buy or sell action from or to Busha Fiat Wallet against a Busha crypto asset.A trade works just the same as a conversion, except that either of the
source_currency and target_currency could be a fiat currency (e.g., NGN, KES).Troubleshooting
Common Conversion Issues:- “Quote expired” during transfer creation: Always generate a fresh quote immediately before attempting to create the transfer.
- “Insufficient balance”: Ensure your Busha account has enough
source_currencyto cover thesource_amountin the quote. - Invalid currency pair: Double-check that Busha supports direct conversion between your chosen
source_currencyandtarget_currency. - 401 Unauthorized: Verify your Authorization header and API key.