npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fipe-table

v1.0.7

Published

Node SDK to retrive information of the FIPE table.

Downloads

1

Readme

Node FIPE Table

:blue_car: :minibus: :truck: Node SDK to retrive information about Brazil's vehicles prices

This SDK is result of a lot of try and error with the API used by FIPE's official website. The website is the only place where FIPE releases its data, therefore, nothing more convienient than a SDK to retrive data directly from the API used by the website.

WARNING: FIPE's API can change without notice, please run the examples to make sure it's working.

Getting Started

Install the module with the classic:

npm i --save fipe-table

Now run the following sample to list all available dates on which the research was made

import { FipeSDK } from 'fipe-table'

const fipeSDK = new FipeSDK()

fipeSDK.fetchAvailableDate()
  .then( date => console.log(date) )

You can list the available brands using the code of the date obtained on the previous sample

import { FipeSDK } from 'fipe-table'

const fipeSDK = new FipeSDK()
const VEHICLE = 'car'
const codeDate = 130

fipeSDK.fetchAvailableBrands(VEHICLE, codeDate)
  .then( brands => console.log(brands) )

It's also possible to ommit the last argument to use the latest date of research

import { FipeSDK } from 'fipe-table'

const fipeSDK = new FipeSDK()
const VEHICLE = 'car'

fipeSDK.fetchAvailableBrands(VEHICLE)
  .then( brands => console.log(brands) )

All the raw HTTP requests performed by this SDK are implemented on this file, it will be usefull to explore all functions available.

There are also more high level functions available on the index file. With these functions you can query using names, e.g.:

import { FipeSDK } from 'fipe-table'

const fipeSDK = new FipeSDK()
const VEHICLE = 'car'

fipeSDK.findModelsByBrand(VEHICLE, 'Fiat')
  .then( models => console.log(models) )

And finally:

import { FipeSDK } from 'fipe-table'

const fipeSDK = new FipeSDK()
const VEHICLE = 'car'

fipeSDK.estimatePrice(VEHICLE, 'Fiat', 'Palio 1.0 Cel. ECON./ITALIA F.Flex 8V 4p', 2014, 1)
  .then( price => console.log(price) )

Also, the VEHICLE argument can be one of: 'car', 'truck', 'motor'.

If you would like to config axios yourself, you can pass the axios instance to the constructor as well. This will be usefull if any error handling for HTTP requests is desired, the sample below always retry when the statusCode of the request is not equal to 200.

const axiosInstance = axios.create({
  baseURL: 'http://veiculos.fipe.org.br/api/veiculos/',
  timeout: 30000,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Referer': 'http://veiculos.fipe.org.br/'
  }
})

axiosInstance.interceptors.response.use(undefined, (err) => {
  if (err.status !== 200 && err.config) {
    return axios(err.config)
  }
  throw err
})

const fipeSDK = new FipeSDK( axiosInstance )

About FIPE

FIPE is the Foundation Institute for Economic Research of the University of Sao Paulo. According to its website, it was founded in 1973 to support the University in the areas of education, projects, research and development of economic and financial indicators. Today, FIPE is one of Brazil's most prestigious developer of financial indicators, beign responsible for (among others) the "FIPE Table", which is an important indicator of the average vehicle prices, and the IPC (Consumer Price Index), which measures the inflation of the State of Sao Paulo. The FIPE Table provides reliable price data in three different categories:

  • Cars and Small Utilities
  • Trucks and Micro bus
  • Motorcycles