Selic

All Contributors

Donate via Paypal Build Status License NPM Dependencies GitHub stars GitHub forks

Node.js TypeScript Jest

A tiny lib to fetch brazilian's selic, ipca and cdi rates.

About

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

How to install

For Node.js via NPM

npm install --save selic

For Node.js via Yarn

yarn add selic

How to use

ESImport

import * as selic from 'selic';

CommonJS

const selic = require('selic');

Fetch selic, ipca and cdi brazilian rates in list version

(async () => {
  const output = await selic.getRatesList();
  /*
   * [
   *  { name: 'Selic', apy: 7.75 },
   *  { name: 'CDI', apy: 7.65 },
   *  { name: 'IPCA', apy: 9.32 },
   * ]
   */
  console.log(output);
})()

Fetch selic, ipca and cdi brazilian rates in object version

(async () => {
  const output = await selic.getRatesObject();
  console.log(output); // { selic: 7.75, cdi: 7.65, ipca: 9.32 }
})()

Get only Selic rate

(async () => {
  const output = await selic.getSelicRate();
  console.log(output); // 7.75
})()

Get only IPCA rate

(async () => {
  const output = await selic.getIpcaRate();
  console.log(output); // 9.32
})()

Get only CDI rate

(async () => {
  const output = await selic.getCdiRate();
  console.log(output); // 7.65
})()

Author

Caio Ribeiro Pereira caio.ribeiro.pereira@gmail.com
Twitter: https://twitter.com/crp_underground
About me: https://crpwebdev.github.io

Contributors ✨

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!