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": "Convert USD to NGN",
"rateToken": "eyJhbGci..."
}
'import requests
url = "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload = {
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "Convert USD to NGN",
"rateToken": "eyJhbGci..."
}
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: 'Convert USD to NGN',
rateToken: 'eyJhbGci...'
})
};
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' => 'Convert USD to NGN',
'rateToken' => 'eyJhbGci...'
]),
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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Swap completed successfully",
"success": true,
"data": {
"transaction": {
"id": "1f2a3b4c-5d6e-4f70-8a91-b2c3d4e5f607",
"transaction_type": "swap",
"status": "completed",
"description": "Convert USD to NGN",
"external_reference": "SWAP_1705314600000",
"fee_amount": 0,
"source_amount": 1000,
"destination_amount": 1405399,
"source_currency": "USD",
"destination_currency": "NGN",
"exchange_rate": 1405.399,
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:00.000Z"
}
}
}{
"status": 400,
"message": "Validation failed",
"code": "ACCOUNT_RESTRICTED",
"errors": [
{
"path": [
"amount"
],
"message": "amount must be a whole number of smallest currency units (e.g. cents)"
}
]
}{
"status": 400,
"message": "Validation failed",
"code": "ACCOUNT_RESTRICTED",
"errors": [
{
"path": [
"amount"
],
"message": "amount must be a whole number of smallest currency units (e.g. cents)"
}
]
}Swap Currency
Swaps funds from one of your wallets into another currency. Amounts are in smallest currency units in both directions. Pass a rateToken from GET /wallet/rates to execute at that quoted rate.
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": "Convert USD to NGN",
"rateToken": "eyJhbGci..."
}
'import requests
url = "https://api.rolla.xyz/api/v1/external/wallet/swap"
payload = {
"fromCurrency": "USD",
"toCurrency": "NGN",
"fromAmount": 1000,
"description": "Convert USD to NGN",
"rateToken": "eyJhbGci..."
}
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: 'Convert USD to NGN',
rateToken: 'eyJhbGci...'
})
};
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' => 'Convert USD to NGN',
'rateToken' => 'eyJhbGci...'
]),
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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\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\": \"Convert USD to NGN\",\n \"rateToken\": \"eyJhbGci...\"\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Swap completed successfully",
"success": true,
"data": {
"transaction": {
"id": "1f2a3b4c-5d6e-4f70-8a91-b2c3d4e5f607",
"transaction_type": "swap",
"status": "completed",
"description": "Convert USD to NGN",
"external_reference": "SWAP_1705314600000",
"fee_amount": 0,
"source_amount": 1000,
"destination_amount": 1405399,
"source_currency": "USD",
"destination_currency": "NGN",
"exchange_rate": 1405.399,
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:00.000Z"
}
}
}{
"status": 400,
"message": "Validation failed",
"code": "ACCOUNT_RESTRICTED",
"errors": [
{
"path": [
"amount"
],
"message": "amount must be a whole number of smallest currency units (e.g. cents)"
}
]
}{
"status": 400,
"message": "Validation failed",
"code": "ACCOUNT_RESTRICTED",
"errors": [
{
"path": [
"amount"
],
"message": "amount must be a whole number of smallest currency units (e.g. cents)"
}
]
}rateToken from the /wallet/rates endpoint to lock in a specific rate. fromAmount is a whole number of the smallest unit of fromCurrency (cents for USD, kobo for NGN), and the amounts on the returned transaction are in smallest units too.
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": "eyJhbGci..."
}'
Example Response
{
"status": 200,
"message": "Swap completed successfully",
"success": true,
"data": {
"transaction": {
"id": "1f2a3b4c-5d6e-4f70-8a91-b2c3d4e5f607",
"transaction_type": "swap",
"status": "completed",
"description": "Convert USD to NGN",
"external_reference": "SWAP_1705314600000",
"fee_amount": 0,
"source_amount": 1000,
"destination_amount": 1405399,
"source_currency": "USD",
"destination_currency": "NGN",
"exchange_rate": 1405.399,
"created_at": "2024-01-15T10:30:00.000Z",
"updated_at": "2024-01-15T10:30:00.000Z"
}
}
}
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
Currency being sold. Currency code, 3 or 4 letters, upper-cased by the server (for example NGN, USD, USDC).
3 - 4"USD"
Currency being bought. Must differ from fromCurrency. Currency code, 3 or 4 letters, upper-cased by the server (for example NGN, USD, USDC).
3 - 4"NGN"
Amount to sell, in the smallest unit of fromCurrency. Whole number of the smallest currency unit (kobo for NGN, cents for USD). Fractional values and amounts below 1 are rejected with a 400.
x >= 11000
Your own description for the transaction. Omitted, Rolla writes one naming the rate and the two amounts.
1 - 500"Convert USD to NGN"
rateToken from GET /wallet/rates, to execute at that quoted rate. Omitted, the swap executes at the current market rate.
"eyJhbGci..."