Swap Currency
curl --request POST \
--url https://api.rolla.xyz/api/v1/external/wallet/swap \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "<string>",
"rateToken": "<string>"
}
'import requests
url = "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload = {
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "<string>",
"rateToken": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fromCurrency: 'USD',
toCurrency: 'NGN',
fromAmount: 1000,
description: '<string>',
rateToken: '<string>'
})
};
fetch('https://api.rolla.xyz/api/v1/external/wallet/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.rolla.xyz/api/v1/external/wallet/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fromCurrency' => 'USD',
'toCurrency' => 'NGN',
'fromAmount' => 1000,
'description' => '<string>',
'rateToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload := strings.NewReader("{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.rolla.xyz/api/v1/external/wallet/swap")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rolla.xyz/api/v1/external/wallet/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Swap completed successfully",
"data": {
"transaction": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"transaction_type": "deposit",
"status": "pending",
"description": "<string>",
"external_reference": "<string>",
"fee_amount": 123,
"fee_transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fee_reference": "FEE-9J76UADV",
"related_transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"related_reference": "<string>",
"source_amount": 123,
"destination_amount": 123,
"source_currency": "<string>",
"destination_currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"fromAmount": 1000,
"toAmount": 1550000,
"rate": 1550
}
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}Wallet
Swap Currency
Swaps funds from one currency to another at the current exchange rate.
POST
/
wallet
/
swap
Swap Currency
curl --request POST \
--url https://api.rolla.xyz/api/v1/external/wallet/swap \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "<string>",
"rateToken": "<string>"
}
'import requests
url = "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload = {
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "<string>",
"rateToken": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fromCurrency: 'USD',
toCurrency: 'NGN',
fromAmount: 1000,
description: '<string>',
rateToken: '<string>'
})
};
fetch('https://api.rolla.xyz/api/v1/external/wallet/swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.rolla.xyz/api/v1/external/wallet/swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fromCurrency' => 'USD',
'toCurrency' => 'NGN',
'fromAmount' => 1000,
'description' => '<string>',
'rateToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload := strings.NewReader("{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.rolla.xyz/api/v1/external/wallet/swap")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rolla.xyz/api/v1/external/wallet/swap")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fromCurrency\": \"USD\",\n \"toCurrency\": \"NGN\",\n \"fromAmount\": 1000,\n \"description\": \"<string>\",\n \"rateToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Swap completed successfully",
"data": {
"transaction": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"transaction_type": "deposit",
"status": "pending",
"description": "<string>",
"external_reference": "<string>",
"fee_amount": 123,
"fee_transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fee_reference": "FEE-9J76UADV",
"related_transaction_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"related_reference": "<string>",
"source_amount": 123,
"destination_amount": 123,
"source_currency": "<string>",
"destination_currency": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
},
"fromAmount": 1000,
"toAmount": 1550000,
"rate": 1550
}
}{
"success": false,
"message": "<string>"
}{
"success": false,
"message": "<string>"
}Swap funds from one currency to another at the current exchange rate. Use a
rateToken from the /wallet/rates endpoint to lock in a specific rate.
Example Request
curl -X POST "https://api.rolla.xyz/api/v1/external/wallet/swap" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "Convert USD to NGN",
"rateToken": "rt_abc123def456"
}'
Example Response
{
"status": 200,
"success": true,
"message": "Swap completed successfully",
"data": {
"transaction": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"transaction_type": "swap",
"status": "completed",
"description": "Convert USD to NGN",
"external_reference": null,
"fee_amount": 0,
"source_amount": 1000,
"destination_amount": 1405399,
"source_currency": "USD",
"destination_currency": "NGN",
"exchange_rate": 1405.3992,
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:05.000Z"
}
}
}
The
fromCurrency and toCurrency must be different. If you don’t provide a rateToken, the swap will execute at the current market rate which may differ from the last quoted rate.Authorizations
Your Rolla API key
Body
application/json
Source currency code
Required string length:
3Example:
"USD"
Destination currency code (must differ from fromCurrency)
Required string length:
3Example:
"NGN"
Amount to swap from source currency
Example:
1000
Optional description
Maximum string length:
500Rate token from /wallet/rates to lock in a specific rate
⌘I