Query rates

Filter by currency, institution and channel. Sort or select the fields you need.

Filter and select fields

Buy and sell are from the institution’s perspective. buy is what it pays when you sell foreign currency; sell is what it charges when you buy. Decimals are strings and a missing side is null.

cURL
curl --fail-with-body 'https://api.divisa.do/v1/rates?currency=USD&kind=commercial&fields=id,institutionId,currency,buy,sell,channel,kind,stale,lastCheckedAt,expiresAt&sort=-buy&limit=10' \
  -H 'Accept: application/json'

Read each page

Use meta.nextCursor as the next request’s cursor. Stop when it is null. Keep the same filters between pages.

JavaScript
const url = new URL('https://api.divisa.do/v1/rates?currency=USD&limit=50');
const rates = [];
let cursor = 0;

do {
  url.searchParams.set('cursor', String(cursor));
  const response = await fetch(url);
  if (!response.ok) throw new Error(`HTTP ${response.status}`);

  const { data, meta } = await response.json();
  rates.push(...data);
  cursor = meta.nextCursor;
} while (cursor !== null);

console.log(rates);

Find the best rate

operation=sell sorts by the highest buy rate; operation=buy by the lowest sell rate. Official references and expired quotes are excluded.

cURL
curl --fail-with-body 'https://api.divisa.do/v1/rates/best?currency=USD&operation=sell' \
  -H 'Accept: application/json'

Dates and provenance

publishedAt is the published date and time; effectiveDate preserves a date without a time; datePrecision declares that precision. lastCheckedAt is the last check. The API retains provenance, validity and evidence for each observation.