A tiny lib to fetch brazilian's selic, ipca and cdi rates.
This is a tiny lib compatible with Node.js v18+ with zero dependencies, supports ESImport and CommonJS.
Basically this lib fetchs the current brazilian SELIC, IPCA and CDI rates, all values in apy (percentage per year).
The Selic rate and IPCA rate are fetched from Banco Central do Brasil
The CDI rate is fetched from B3
npm install --save selic
yarn add selic
import * as selic from 'selic';
const selic = require('selic');
(async () => {
const output = await selic.getRatesList();
/*
* [
* { name: 'Selic', apy: 7.75 },
* { name: 'CDI', apy: 7.65 },
* { name: 'IPCA', apy: 9.32 },
* ]
*/
console.log(output);
})()
(async () => {
const output = await selic.getRatesObject();
console.log(output); // { selic: 7.75, cdi: 7.65, ipca: 9.32 }
})()
(async () => {
const output = await selic.getSelicRate();
console.log(output); // 7.75
})()
(async () => {
const output = await selic.getIpcaRate();
console.log(output); // 9.32
})()
(async () => {
const output = await selic.getCdiRate();
console.log(output); // 7.65
})()
Caio Ribeiro Pereira [email protected]
Twitter: https://twitter.com/crp_underground
About me: https://crpwebdev.github.io
Thanks goes to these wonderful people (emoji key):
Michael Wu 💻 |
Caio Ribeiro Pereira 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!