Rates
This endpoint retrieves the current exchange rates for the requested currency pairs.
HTTP Request via SSL
POST '/api/v1/da/rates'
Header Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| Authorization | yes | "Bearer merchant_private_key" - The api key as a string. |
| Content-Type | yes | All request bodies should have content type application/json and be valid JSON. |
Request Body Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| rates | yes | An array of currency pair objects. Each object contains a base and a quote currency. |
| session_token | yes | Authorization token. |
Response Parameters
| Parameter | Description |
|---|---|
| success | true/false |
| status | The HTTP status code of the response |
| rates | A hash with the rates for each currency pair requested. Each currency pair (e.g., "LTC-EUR") contains a price. |
- Shell
- PHP
- Java
curl "https://business.payments.defexa.io/api/v1/da/rates" \
-H "Authorization: Bearer merchant_private_key" \
-H "Content-Type: application/json" \
-d '{
"session_token": "f3a728b408fadd87f",
"rates": [
{ "base": "LTC", "quote": "EUR" },
{ "base": "TRX", "quote": "USD" }
]
}'<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://business.payments.defexa.io/api/v1/da/rates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer merchant_private_key",
"Content-Type: application/json"
),
CURLOPT_POSTFIELDS => json_encode([
"rates" => [
["base" => "LTC", "quote" => "EUR"],
["base" => "TRX", "quote" => "USD"]
]
]),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(
MediaType.parse("application/json"),
"{\n" +
" \"rates\": [\n" +
" { \"base\": \"LTC\", \"quote\": \"EUR\" },\n" +
" { \"base\": \"TRX\", \"quote\": \"USD\" }\n" +
" ],\n" +
" \"session_token\": \"f3a728b408fadd87f\"\n" +
"}"
);
Request request = new Request.Builder()
.url("https://business.payments.defexa.io/api/v1/da/rates")
.post(body)
.addHeader("Authorization", "Bearer merchant_private_key")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();Return status 200 and JSON:
{
"success": true,
"status": 200,
"rates": {
"LTCEUR": {
"amount": 1,
"price": 100.5
},
"TRXUSD": {
"amount": 1,
"price": 0.24268752164476534
}
}
}