1.2.2 • Published 4 years ago
fundamentus-unofficial-api v1.2.2
Fundamentus Unofficial API
This module provides an api to get data from Brazilian stock shares.
The truth of source is Fundamentus, a website that provides financial and fundamentalist information about companies listed on the Bovespa.
Content
Installation
$ npm install fundamentus-unofficial-api --save
Usage
Importing
const FundamentusAPI = require('fundamentus-unofficial-api') // CommonJS
// or
import FundamentusAPI from 'fundamentus-unofficial-api' // ESM
Fetching details about share
const share = await FundamentusAPI.fetch('petr3')
Output
- All fields are parsed to its correct data type - i.e. '"1,78%" => 0.0178
- If a field is
null
, it means there is no data available from Fundamentus
Fetching quotation history
const quotationHistory = await FundamentusAPI.fetchQuotationHistory('petr3')
Output
// console.log(history)
QuotationHistory {
share: 'PETR3',
history: [
{ date: '2020-04-09', quotation: 16.86 },
...
]
}
Methods
fetchQuotationHistory
returns a QuotationHistory
instance which we can manipulate to get only a specific range of timeline or quotation value using the following methods:
- last
- minDate
- maxDate
- minQuotation
- maxQuotation
Examples
const quotationHistory = await FundamentusAPI.fetchQuotationHistory('petr3')
// Returns the history range which the quotation value was, at least, R$11.43 since January 1st, 2020
quotationHistory.minQuotation(11.43).minDate('2020-01-01')
const quotationHistory = await FundamentusAPI.fetchQuotationHistory('petr3')
// Returns the history in the last 10 days
quotationHistory.last(10)
Fetching earnings history
const earningsHistory = await FundamentusAPI.fetchEarningsHistory('petr3')
Output
// console.log(history)
EarningsHistory {
share: 'PETR3',
history: [
{ date: '2008-04-04', value: 0.05, type: 'DIVIDENDO', perShare: 1 },
...
]
}
Methods
fetchEarningsHistory
returns a EarningsHistory
instance which we can manipulate to get only a specific range of timeline, value or by type using the following methods:
- minDate
- maxDate
- minValue
- maxValue
- filterByType
Examples
const earningsHistory = await FundamentusAPI.fetchEarningsHistory('petr3')
// Returns all the earnings of 2019
earningsHistory.minDate('2019-01-01').maxDate('2019-12-31')
const earningsHistory = await FundamentusAPI.fetchEarningsHistory('petr3')
// Returns earnings by dividends with min value of 0.5
earningsHistory.filterByType('DIVIDENDO').minValue(0.5)
Getting help
If you need help, want to make a suggestion or encounter a bug, please contact me: https://github.com/margato/fundamentus-unofficial-api/issues