-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-nbu-api.mjs
More file actions
29 lines (21 loc) · 787 Bytes
/
Copy pathtest-nbu-api.mjs
File metadata and controls
29 lines (21 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Simple test to verify NBU API integration
import fetch from 'node-fetch';
async function testNBUAPI() {
const testDate = '20241201'; // December 1, 2024
const currency = 'USD';
const url = `https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?valcode=${currency}&date=${testDate}&json`;
console.log(`Testing NBU API for ${currency} on ${testDate}...`);
console.log(`URL: ${url}`);
try {
const response = await fetch(url);
const data = await response.json();
console.log('\n✅ API Response:');
console.log(JSON.stringify(data, null, 2));
if (data && data.length > 0) {
console.log(`\n✅ Exchange rate: 1 ${data[0].cc} = ${data[0].rate} UAH`);
}
} catch (error) {
console.error('❌ Error:', error);
}
}
testNBUAPI();