A tiny lib to scrap brazilian's selic, poupança and cdi rates.
This is a tiny lib compatible with Node.js v11+ and TypeScript, with zero dependencies, supports ES Import and CommonJS.
Basically this lib fetchs the current brazilian SELIC rates and CDI rates, all values in apy (percentage per year).
The Selic rate is fetched from Banco Central do Brasil The CDI rate is fetched from CETIP
npm install --save selic
import { Selic } from 'selic';
const { Selic } = require('selic');
(async () => {
const selic = new Selic();
const rates = await selic.getAllRates();
/*
* [
* { name: 'Selic', apy: 7.75 },
* { name: 'CDI', apy: 7.65 }
* ]
*/
console.log(rates);
})()
(async () => {
const selic = new Selic();
const rates = await selic.getRatesObject();
/*
* { selic: 7.75, cdi: 7.65 }
*/
console.log(rates);
})()
(async () => {
const selic = new Selic();
const selicValue = await selic.getSelicRate();
console.log(selicValue); // 7.75
})()
(async () => {
const selic = new Selic();
const cdiValue = await selic.getCdiRate();
console.log(cdiValue); // 7.65
})()
Caio Ribeiro Pereira caio.ribeiro.pereira@gmail.com
Twitter: https://twitter.com/crp_underground
About me: https://crpwebdev.github.io