Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "GET";
const id = required("LEDIG_QUOTE_ID");
const path = `/v1/quotes/${encodeURIComponent(id)}`;
const pathWithQuery = path;
const rawBody = "";
const headers = { "Accept": "application/json" };
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"id": "quote_example_001",
"profileId": "profile_example_001",
"reference": "invoice-example-001",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"sourceAmount": "100.00",
"destinationAmount": "100.00",
"rate": "1.00",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"feeAmount": "0.50",
"feeCurrency": "USDT",
"sourceDebitAmount": "100.50",
"payoutFeeAmount": "0",
"payoutFeeCurrency": "USD",
"payoutFeeSourceAmount": "0",
"totalFeeAmount": "0.50",
"totalFeeCurrency": "USDT",
"totalSourceDebitAmount": "100.50",
"meta": {
"rate": {
"product": "USDTUSD",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"rate": "1.00",
"side": "sell",
"type": "fixed"
}
},
"expiresAt": "2026-01-15T10:05:00.000Z",
"status": "pending"
}
}{
"status": "error",
"code": "UNAUTHORIZED",
"message": "Authentication is required."
}{
"status": "error",
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action."
}{
"status": "error",
"code": "NOT_FOUND",
"message": "The requested resource was not found."
}{
"status": "error",
"code": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}Quotes
View a quote
Check a quote’s amounts, rate, status and expiry.
GET
/
v1
/
quotes
/
{id}
Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "GET";
const id = required("LEDIG_QUOTE_ID");
const path = `/v1/quotes/${encodeURIComponent(id)}`;
const pathWithQuery = path;
const rawBody = "";
const headers = { "Accept": "application/json" };
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"id": "quote_example_001",
"profileId": "profile_example_001",
"reference": "invoice-example-001",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"sourceAmount": "100.00",
"destinationAmount": "100.00",
"rate": "1.00",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z",
"feeAmount": "0.50",
"feeCurrency": "USDT",
"sourceDebitAmount": "100.50",
"payoutFeeAmount": "0",
"payoutFeeCurrency": "USD",
"payoutFeeSourceAmount": "0",
"totalFeeAmount": "0.50",
"totalFeeCurrency": "USDT",
"totalSourceDebitAmount": "100.50",
"meta": {
"rate": {
"product": "USDTUSD",
"sourceCurrency": "USDT",
"destinationCurrency": "USD",
"rate": "1.00",
"side": "sell",
"type": "fixed"
}
},
"expiresAt": "2026-01-15T10:05:00.000Z",
"status": "pending"
}
}{
"status": "error",
"code": "UNAUTHORIZED",
"message": "Authentication is required."
}{
"status": "error",
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action."
}{
"status": "error",
"code": "NOT_FOUND",
"message": "The requested resource was not found."
}{
"status": "error",
"code": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}Required scope:
quotes:read
Review the terms and expiresAt before creating a transfer. A quote can be pending, accepted or expired. Only a pending, unexpired quote can start a new transfer.