DIVISA API / PRODUCCIÓN
Integrate from Node.js and TypeScript
Use Node.js fetch and load DIVISA_API_KEY from your server secret store. This request uses real rates and consumes quota.
curl --fail-with-body 'https://api.divisa.do/v1/rates?currency=USD&freshness=current&limit=5' \
-H 'Accept: application/json' \
-H "Authorization: Bearer $DIVISA_API_KEY"const response = await fetch(
'https://api.divisa.do/v1/rates?currency=USD&freshness=current&limit=5',
{ headers: { Accept: 'application/json', Authorization: `Bearer ${process.env.DIVISA_API_KEY}` } }
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const { data, meta } = await response.json();
console.log(data);Backend integration checklist
- Create an application and a backend key. Keep the secret out of client code.
- Query the appropriate currency, channel and commercial or reference type. Buy and sell use the entity perspective.
- Preserve decimal values as strings. Use decimal arithmetic for calculations, not Number or parseFloat.
- Store the chosen rate, entity, source, timestamps and temporal precision with the result. Attribute Divisa and display the date.
- When a side is missing, expired or uncovered, expose that absence and require an explicit decision. Never invent a value.
- Check the request ID in Usage after the first authenticated request.
The initial integration is informational. Using rates for charges or fiscal documents requires a specific assessment with the product owner.