1.0.1 • Published 2 years ago
currensees-js-sdk v1.0.1
Currency API SDK
Develop and deploy applications, mobile and web, with popular JavaScript Frameworks using Currency API SDK.
Install
yarn add currensees-js-sdk
# or
npm i currensees-js-sdk
Example of Usage
import {
login,
convertCurrency,
convertAllCurrencies,
getAllCurrencies,
getCurrencyById,
getAllHistoricalRates,
getHistoricalRateById,
} from 'currensees-js-sdk';
async function testCurrensees() {
try {
const credentials = {
username: 'your_username',
password: 'your_password',
};
const response = await login(credentials);
console.log('Login successful:', response);
// Test the convertCurrency function
const conversionRequest = {
date: '2023_04_02',
base_currency: 'GBP',
target_currency: 'CAD',
amount: '500',
};
const conversionResponse = await convertCurrency(response.token, conversionRequest);
console.log('Conversion successful:', conversionResponse);
// Test the convertAllCurrencies function
const convertAllRequest = {
base_currency: 'GBP',
amount: 120,
date: '2023_04_02',
};
const convertAllResponse = await convertAllCurrencies(response.token, convertAllRequest);
console.log('Convert all currencies successful:', convertAllResponse);
// Test the getAllCurrencies function
const getAllCurrenciesRequest = {
username: credentials.username,
day: 2,
month: 4,
year: 2023,
};
const getAllCurrenciesResponse = await getAllCurrencies(response.token, getAllCurrenciesRequest);
console.log('Get all currencies successful:', getAllCurrenciesResponse);
// Test the getCurrencyById function
const uuid = 'some-uuid'; // Replace with a valid UUID for a currency
const getCurrencyByIdRequest = {
uuid,
username: credentials.username,
day: 2,
month: 4,
year: 2023,
};
const currencyByIdResponse = await getCurrencyById(response.token, getCurrencyByIdRequest);
console.log('Get currency by ID successful:', currencyByIdResponse);
// Test the getAllHistoricalRates function
const getAllHistoricalRatesRequest = {
username: credentials.username,
date: '2023_04_02',
day: 2,
month: 4,
year: 2023,
};
const getAllHistoricalRatesResponse = await getAllHistoricalRates(response.token, getAllHistoricalRatesRequest);
console.log('Get all historical rates successful:', getAllHistoricalRatesResponse);
// Test the getHistoricalRateById function
const historicalUuid = 'some-uuid'; // Replace with a valid UUID for a historical rate
const getHistoricalRateByIdRequest = {
uuid: historicalUuid,
username: credentials.username,
day: 2,
month: 4,
year: 2023,
date_string: '2023_04_02',
};
const historicalRateByIdResponse = await getHistoricalRateById(response.token, getHistoricalRateByIdRequest);
console.log('Get historical rate by ID successful:', historicalRateByIdResponse);
} catch (error) {
if (error instanceof Error) {
console.error('Error:', error.message);
} else {
console.error('An unknown error occurred:', error);
}
}
}
testCurrensees();
The Currency API documentation is available here. If you need further assistance, don't hesitate to contact us.
License
This project is licensed under the BSD 3-Clause License.
Copyright
(c) 2023 Moat Systems Limited.