├── .husky └── pre-commit ├── .prettierrc.json ├── .gitignore ├── src ├── types │ ├── fipe │ │ ├── model.ts │ │ ├── vehicle.ts │ │ ├── brands.ts │ │ ├── tables.ts │ │ └── price.ts │ ├── taxes.ts │ ├── ddd.ts │ ├── ibge │ │ ├── city.ts │ │ ├── country.ts │ │ └── state.ts │ ├── cptec │ │ ├── city.ts │ │ └── weather │ │ │ ├── airport.ts │ │ │ ├── capital.ts │ │ │ ├── forecast.ts │ │ │ └── oceans.ts │ ├── holidays.ts │ ├── bank.ts │ ├── exchange │ │ ├── currency.ts │ │ └── rates.ts │ ├── ncm.ts │ ├── pix.ts │ ├── registerBr.ts │ ├── isbn.ts │ ├── cvm.ts │ ├── cep.ts │ └── cnpj.ts ├── routes │ ├── cptec │ │ ├── index.ts │ │ ├── weather │ │ │ ├── index.ts │ │ │ ├── capital.ts │ │ │ ├── airport.ts │ │ │ ├── ocean.ts │ │ │ └── forecast.ts │ │ └── city.ts │ ├── exchange │ │ ├── index.ts │ │ ├── currency.ts │ │ └── rates.ts │ ├── ibge │ │ ├── index.ts │ │ ├── state.ts │ │ ├── city.ts │ │ └── country.ts │ ├── fipe │ │ ├── index.ts │ │ ├── tables.ts │ │ ├── price.ts │ │ ├── brands.ts │ │ └── vehicles.ts │ ├── ddd.ts │ ├── pix.ts │ ├── holidays.ts │ ├── registerBr.ts │ ├── cep.ts │ ├── cnpj.ts │ ├── cepV1.ts │ ├── bank.ts │ ├── taxes.ts │ ├── cvm.ts │ ├── isbn.ts │ └── ncm.ts ├── utils │ └── format.ts ├── service │ └── api.service.ts └── index.ts ├── jest.config.js ├── test ├── module │ ├── cjs │ │ └── package.json │ ├── mjs │ │ └── package.json │ ├── ts │ │ └── package.json │ ├── ts-require │ │ └── package.json │ ├── cts │ │ └── package.json │ └── mts │ │ └── package.json └── modules.spec.ts ├── eslint.config.mjs ├── .github └── workflows │ └── ci.yml ├── package.json ├── README.md └── tsconfig.json /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npm run build 2 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "endOfLine": "lf" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | coverage 4 | test/module/**/assert.* 5 | -------------------------------------------------------------------------------- /src/types/fipe/model.ts: -------------------------------------------------------------------------------- 1 | export interface VehicleModel { 2 | modelo: string; 3 | } 4 | -------------------------------------------------------------------------------- /src/types/fipe/vehicle.ts: -------------------------------------------------------------------------------- 1 | export type VehicleType = "caminhoes" | "carros" | "motos"; 2 | -------------------------------------------------------------------------------- /src/types/taxes.ts: -------------------------------------------------------------------------------- 1 | export interface Taxe { 2 | nome: string; 3 | valor: number; 4 | } 5 | -------------------------------------------------------------------------------- /src/types/ddd.ts: -------------------------------------------------------------------------------- 1 | export interface DDD { 2 | state: string; 3 | cities: string[]; 4 | } 5 | -------------------------------------------------------------------------------- /src/routes/cptec/index.ts: -------------------------------------------------------------------------------- 1 | export * as weather from "./weather"; 2 | export * as city from "./city"; 3 | -------------------------------------------------------------------------------- /src/types/fipe/brands.ts: -------------------------------------------------------------------------------- 1 | export interface Brand { 2 | nome: string; 3 | valor: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/types/fipe/tables.ts: -------------------------------------------------------------------------------- 1 | export interface Tables { 2 | codigo: number; 3 | mes: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/types/ibge/city.ts: -------------------------------------------------------------------------------- 1 | export interface City { 2 | nome: string; 3 | codigo_ibge: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/routes/exchange/index.ts: -------------------------------------------------------------------------------- 1 | export * as currency from "./currency"; 2 | export * as rates from "./rates"; 3 | -------------------------------------------------------------------------------- /src/types/ibge/country.ts: -------------------------------------------------------------------------------- 1 | export interface Country { 2 | nome: string; 3 | codigo_ibge: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/utils/format.ts: -------------------------------------------------------------------------------- 1 | export function onlyNumbers(value: string) { 2 | return value.replace(/\D/g, ""); 3 | } 4 | -------------------------------------------------------------------------------- /src/types/cptec/city.ts: -------------------------------------------------------------------------------- 1 | export interface City { 2 | nome: string; 3 | estado: string; 4 | id: number; 5 | } 6 | -------------------------------------------------------------------------------- /src/types/holidays.ts: -------------------------------------------------------------------------------- 1 | export interface Holiday { 2 | date: string; 3 | name: string; 4 | type: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/types/bank.ts: -------------------------------------------------------------------------------- 1 | export interface Bank { 2 | ispb: string; 3 | name: string; 4 | code: number; 5 | fullName: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/types/exchange/currency.ts: -------------------------------------------------------------------------------- 1 | export interface Currency { 2 | simbolo: string; 3 | nome: string; 4 | tipo_moeda: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/routes/ibge/index.ts: -------------------------------------------------------------------------------- 1 | export * as country from "./country"; 2 | export * as state from "./state"; 3 | export * as city from "./city"; 4 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line 2 | module.exports = { 3 | transform: { 4 | "^.+\\.(t|j)sx?$": "@swc/jest", 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /test/module/cjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cjs-entrypoint-test", 3 | "dependencies": { 4 | "brasilapi-js": "file:../../../dist/" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/module/mjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "esm-entrypoint-test", 3 | "type": "module", 4 | "dependencies": { 5 | "brasilapi-js": "file:../../../dist/" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/routes/fipe/index.ts: -------------------------------------------------------------------------------- 1 | export * as brands from "./brands"; 2 | export * as price from "./price"; 3 | export * as tables from "./tables"; 4 | export * as vehicles from "./vehicles"; 5 | -------------------------------------------------------------------------------- /src/routes/cptec/weather/index.ts: -------------------------------------------------------------------------------- 1 | export * as airport from "./airport"; 2 | export * as capital from "./capital"; 3 | export * as ocean from "./ocean"; 4 | export * as forecast from "./forecast"; 5 | -------------------------------------------------------------------------------- /src/types/ncm.ts: -------------------------------------------------------------------------------- 1 | export interface NCM { 2 | codigo: string; 3 | descricao: string; 4 | data_inicio: string; 5 | data_fim: string; 6 | tipo_ato: string; 7 | numero_ato: string; 8 | ano_ato: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/types/pix.ts: -------------------------------------------------------------------------------- 1 | export interface Pix { 2 | codigo: string; 3 | descricao: string; 4 | data_inicio: string; 5 | data_fim: string; 6 | tipo_ato: string; 7 | numero_ato: string; 8 | ano_ato: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/routes/ddd.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { DDD } from "../types/ddd"; 3 | 4 | const endpoint = "/ddd/v1/"; 5 | 6 | export const getBy = (ddd: string) => { 7 | return get(endpoint + ddd); 8 | }; 9 | -------------------------------------------------------------------------------- /src/routes/pix.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { Pix } from "../types/pix"; 3 | 4 | const endpoint = "/pix/v1/participants/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | -------------------------------------------------------------------------------- /src/types/ibge/state.ts: -------------------------------------------------------------------------------- 1 | export interface State { 2 | id: number; 3 | sigla: string; 4 | nome: string; 5 | regiao: Region; 6 | } 7 | 8 | export interface Region { 9 | id: number; 10 | sigla: string; 11 | nome: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/types/registerBr.ts: -------------------------------------------------------------------------------- 1 | export interface RegisterBr { 2 | status_code: number; 3 | status: string; 4 | fqdn: string; 5 | hosts: string[]; 6 | "publication-status": string; 7 | "expires-at": string; 8 | suggestions: string[]; 9 | } 10 | -------------------------------------------------------------------------------- /src/routes/fipe/tables.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Tables } from "../../types/fipe/tables"; 3 | 4 | const endpoint = "/fipe/tabelas/v1/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | -------------------------------------------------------------------------------- /src/routes/holidays.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { Holiday } from "../types/holidays"; 3 | 4 | const endpoint = "/feriados/v1/"; 5 | 6 | export const getBy = (year: string) => { 7 | return get(endpoint + year); 8 | }; 9 | -------------------------------------------------------------------------------- /src/routes/exchange/currency.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Currency } from "../../types/exchange/currency"; 3 | 4 | const endpoint = "/cambio/v1/moedas"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | -------------------------------------------------------------------------------- /src/routes/registerBr.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { RegisterBr } from "../types/registerBr"; 3 | 4 | const endpoint = "/registrobr/v1/"; 5 | 6 | export const getBy = (domain: string) => { 7 | return get(endpoint + domain); 8 | }; 9 | -------------------------------------------------------------------------------- /src/routes/cptec/weather/capital.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../../service/api.service"; 2 | import { Capital } from "../../../types/cptec/weather/capital"; 3 | 4 | const endpoint = "cptec/v1/clima/capital/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | -------------------------------------------------------------------------------- /test/module/ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts-entrypoint-test", 3 | "dependencies": { 4 | "brasilapi-js": "file:../../../dist/" 5 | }, 6 | "devDependencies": { 7 | "@types/node": "^18.19.93", 8 | "tsx": "^4.19.4", 9 | "typescript": "^5.8.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/module/ts-require/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts-require-entrypoint-test", 3 | "dependencies": { 4 | "brasilapi-js": "file:../../../dist/" 5 | }, 6 | "devDependencies": { 7 | "@types/node": "^18.19.93", 8 | "tsx": "^4.19.4", 9 | "typescript": "^5.8.3" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/routes/cep.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { CepV2 } from "../types/cep"; 3 | import { onlyNumbers } from "../utils/format"; 4 | 5 | const endpointV2 = "/cep/v2/"; 6 | 7 | export const getBy = (cep: string) => { 8 | return get(endpointV2 + onlyNumbers(cep)); 9 | }; 10 | -------------------------------------------------------------------------------- /src/routes/cnpj.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { CNPJ } from "../types/cnpj"; 3 | import { onlyNumbers } from "../utils/format"; 4 | 5 | const endpoint = "/cnpj/v1/"; 6 | 7 | export const getBy = (cnpj: string) => { 8 | return get(endpoint + onlyNumbers(cnpj)); 9 | }; 10 | -------------------------------------------------------------------------------- /src/routes/cptec/weather/airport.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../../service/api.service"; 2 | import { Airport } from "../../../types/cptec/weather/airport"; 3 | 4 | const endpoint = "cptec/v1/clima/aeroporto/"; 5 | 6 | export const getBy = (icaoCode: string) => { 7 | return get(endpoint + icaoCode); 8 | }; 9 | -------------------------------------------------------------------------------- /test/module/cts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cts-entrypoint-test", 3 | "type": "commonjs", 4 | "dependencies": { 5 | "brasilapi-js": "file:../../../dist/" 6 | }, 7 | "devDependencies": { 8 | "@types/node": "^18.19.93", 9 | "tsx": "^4.19.4", 10 | "typescript": "^5.8.3" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/module/mts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mts-entrypoint-test", 3 | "type": "module", 4 | "dependencies": { 5 | "brasilapi-js": "file:../../../dist/" 6 | }, 7 | "devDependencies": { 8 | "@types/node": "^18.19.93", 9 | "tsx": "^4.19.4", 10 | "typescript": "^5.8.3" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/routes/cepV1.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { CepV1 } from "../types/cep"; 3 | import { onlyNumbers } from "../utils/format"; 4 | 5 | const endpointV1 = "/cep/v1/"; 6 | 7 | export const getBy = (cep: string) => { 8 | return get(endpointV1 + onlyNumbers(cep)); 9 | }; 10 | -------------------------------------------------------------------------------- /src/types/fipe/price.ts: -------------------------------------------------------------------------------- 1 | export interface Price { 2 | valor: string; 3 | marca: string; 4 | modelo: string; 5 | anoModelo: number; 6 | combustivel: string; 7 | codigoFipe: string; 8 | mesReferencia: string; 9 | tipoVeiculo: number; 10 | siglaCombustivel: string; 11 | dataConsulta: string; 12 | } 13 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | import eslint from '@eslint/js'; 4 | import tseslint from 'typescript-eslint'; 5 | 6 | export default tseslint.config( 7 | eslint.configs.recommended, 8 | tseslint.configs.recommended, 9 | { 10 | ignores: ["node_modules/**", "dist/**", "test/module/**"], 11 | } 12 | ); 13 | -------------------------------------------------------------------------------- /src/routes/bank.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { Bank } from "../types/bank"; 3 | 4 | const endpoint = "/banks/v1/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | 10 | export const getBy = (code: number) => { 11 | return get(endpoint + code); 12 | }; 13 | -------------------------------------------------------------------------------- /src/service/api.service.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export const instance = axios.create({ 4 | baseURL: "https://brasilapi.com.br/api", 5 | headers: { 6 | "Content-type": "application/json", 7 | }, 8 | }); 9 | 10 | export function get(endpoint: string) { 11 | return instance.get(endpoint); 12 | } 13 | -------------------------------------------------------------------------------- /src/routes/taxes.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { Taxe } from "../types/taxes"; 3 | 4 | const endpoint = "/taxas/v1/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | 10 | export const getBy = (sigla: string) => { 11 | return get(endpoint + sigla); 12 | }; 13 | -------------------------------------------------------------------------------- /src/types/cptec/weather/airport.ts: -------------------------------------------------------------------------------- 1 | export interface Airport { 2 | codigo_icao: string; 3 | atualizado_em: string; 4 | pressao_atmosferica: string; 5 | visibilidade: string; 6 | vento: number; 7 | direcao_vento: number; 8 | umidade: number; 9 | condicao: string; 10 | condicao_Desc: string; 11 | temp: number; 12 | } 13 | -------------------------------------------------------------------------------- /src/types/cptec/weather/capital.ts: -------------------------------------------------------------------------------- 1 | export interface Capital { 2 | codigo_icao: string; 3 | atualizado_em: string; 4 | pressao_atmosferica: string; 5 | visibilidade: string; 6 | vento: number; 7 | direcao_vento: number; 8 | umidade: number; 9 | condicao: string; 10 | condicao_Desc: string; 11 | temp: number; 12 | } 13 | -------------------------------------------------------------------------------- /src/routes/exchange/rates.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Exchange } from "../../types/exchange/rates"; 3 | 4 | const endpoint = "/cambio/v1/cotacao"; 5 | 6 | export const getBy = (currency: string, date: string) => { 7 | const url = `${endpoint}/${currency}/${date}`; 8 | return get(url); 9 | }; 10 | -------------------------------------------------------------------------------- /src/types/cptec/weather/forecast.ts: -------------------------------------------------------------------------------- 1 | export interface Forecast { 2 | cidade: string; 3 | estado: string; 4 | atualizado_em: string; 5 | clima: Clima[]; 6 | } 7 | 8 | export interface Clima { 9 | data: string; 10 | condicao: string; 11 | min: number; 12 | max: number; 13 | indice_uv: number; 14 | condicao_desc: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/routes/ibge/state.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { State } from "../../types/ibge/state"; 3 | 4 | const endpoint = "/ibge/uf/v1/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | 10 | export const getBy = (code: string) => { 11 | return get(endpoint + code); 12 | }; 13 | -------------------------------------------------------------------------------- /src/types/exchange/rates.ts: -------------------------------------------------------------------------------- 1 | export interface Exchange { 2 | cotacoes: Rate[]; 3 | moeda: string; 4 | data: string; 5 | } 6 | 7 | export interface Rate { 8 | paridade_compra: number; 9 | paridade_venda: number; 10 | cotacao_compra: number; 11 | cotacao_venda: number; 12 | data_hora_cotacao: string; 13 | tipo_boletim: string; 14 | } 15 | -------------------------------------------------------------------------------- /src/routes/cptec/city.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { City } from "../../types/cptec/city"; 3 | 4 | const endpointCity = "/cptec/v1/cidade/"; 5 | 6 | export const getAll = () => { 7 | return get(endpointCity); 8 | }; 9 | 10 | export const getBy = (cityName: string) => { 11 | return get(endpointCity + cityName); 12 | }; 13 | -------------------------------------------------------------------------------- /src/routes/cptec/weather/ocean.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../../service/api.service"; 2 | import { Oceans } from "../../../types/cptec/weather/oceans"; 3 | 4 | const endpoint = "cptec/v1/ondas/"; 5 | 6 | export const getBy = (cityCode: number, days?: number) => { 7 | let url = endpoint + cityCode; 8 | if (days) url += "/" + days; 9 | 10 | return get(url); 11 | }; 12 | -------------------------------------------------------------------------------- /src/routes/cvm.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { CVM } from "../types/cvm"; 3 | import { onlyNumbers } from "../utils/format"; 4 | 5 | const endpoint = "/cvm/corretoras/v1/"; 6 | 7 | export const getAll = () => { 8 | return get(endpoint); 9 | }; 10 | 11 | export const getBy = (cnpj: string) => { 12 | return get(endpoint + onlyNumbers(cnpj)); 13 | }; 14 | -------------------------------------------------------------------------------- /src/routes/cptec/weather/forecast.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../../service/api.service"; 2 | import { Forecast } from "../../../types/cptec/weather/forecast"; 3 | 4 | const endpoint = "cptec/v1/clima/previsao/"; 5 | 6 | export const getBy = (cityCode: number, days?: number) => { 7 | let url = endpoint + cityCode; 8 | if (days) url += "/" + days; 9 | 10 | return get(url); 11 | }; 12 | -------------------------------------------------------------------------------- /src/routes/fipe/price.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Price } from "../../types/fipe/price"; 3 | 4 | const endpoint = "/fipe/preco/v1/"; 5 | 6 | export const getBy = (codigoFipe: string, tabela_referencia?: number) => { 7 | let url = endpoint + codigoFipe; 8 | if (tabela_referencia) { 9 | url += "?tabela_referencia" + tabela_referencia; 10 | } 11 | return get(url); 12 | }; 13 | -------------------------------------------------------------------------------- /src/routes/isbn.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { ISBN } from "../types/isbn"; 3 | 4 | const endpoint = "/isbn/v1/"; 5 | 6 | export const getBy = ( 7 | isbn: string, 8 | provider?: "cbl" | "mercado-editorial" | "open-library" | "google-books", 9 | ) => { 10 | let url = endpoint + isbn; 11 | if (provider) { 12 | url += "?provider=" + provider; 13 | } 14 | return get(url); 15 | }; 16 | -------------------------------------------------------------------------------- /src/routes/ibge/city.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { City } from "../../types/ibge/city"; 3 | 4 | const endpoint = "/ibge/municipios/v1/"; 5 | 6 | export const getBy = ( 7 | siglaUF: string, 8 | providers?: "dados-abertos-br" | "gov" | "wikipedia", 9 | ) => { 10 | let url = endpoint + siglaUF; 11 | if (providers) { 12 | url += "?providers=" + providers; 13 | } 14 | 15 | return get(url); 16 | }; 17 | -------------------------------------------------------------------------------- /src/routes/fipe/brands.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Brand } from "../../types/fipe/brands"; 3 | import { VehicleType } from "../../types/fipe/vehicle"; 4 | 5 | const endpoint = "/fipe/marcas/v1/"; 6 | 7 | export const getBy = (typeVehicle: VehicleType, reference_table?: number) => { 8 | let url = endpoint + typeVehicle; 9 | if (reference_table) { 10 | url += "?tabela_referencia" + reference_table; 11 | } 12 | return get(url); 13 | }; 14 | -------------------------------------------------------------------------------- /src/routes/ncm.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../service/api.service"; 2 | import { NCM } from "../types/ncm"; 3 | 4 | const endpoint = "/ncm/v1/"; 5 | 6 | export const getAll = () => { 7 | return get(endpoint); 8 | }; 9 | 10 | export const getBy = (code: string) => { 11 | return get(endpoint + code); 12 | }; 13 | 14 | export const search = (code: string) => { 15 | const url = endpoint.substring(0, endpoint.length - 1) + "?search=" + code; 16 | return get(url); 17 | }; 18 | -------------------------------------------------------------------------------- /src/types/cptec/weather/oceans.ts: -------------------------------------------------------------------------------- 1 | export interface Oceans { 2 | cidade: string; 3 | estado: string; 4 | atualizado_em: string; 5 | ondas: Ocean[]; 6 | } 7 | 8 | export interface Ocean { 9 | data: string; 10 | dados_ondas: OceanData[]; 11 | } 12 | 13 | export interface OceanData { 14 | vento: number; 15 | direcao_vento: string; 16 | direcao_vento_desc: string; 17 | altura_onda: number; 18 | direcao_onda: string; 19 | direcao_onda_desc: string; 20 | agitacao: string; 21 | hora: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/types/isbn.ts: -------------------------------------------------------------------------------- 1 | export interface ISBN { 2 | isbn: string; 3 | title: string; 4 | subtitle: unknown; 5 | authors: string[]; 6 | publisher: string; 7 | synopsis: string; 8 | dimensions: Dimensions; 9 | year: number; 10 | format: string; 11 | page_count: number; 12 | subjects: string[]; 13 | location: string; 14 | retail_price: unknown; 15 | cover_url: unknown; 16 | provider: string; 17 | } 18 | 19 | export interface Dimensions { 20 | width: number; 21 | height: number; 22 | unit: string; 23 | } 24 | -------------------------------------------------------------------------------- /src/types/cvm.ts: -------------------------------------------------------------------------------- 1 | export interface CVM { 2 | bairro: string; 3 | cep: string; 4 | cnpj: string; 5 | codigo_cvm: string; 6 | complemento: string; 7 | data_inicio_situacao: string; 8 | data_patrimonio_liquido: string; 9 | data_registro: string; 10 | email: string; 11 | logradouro: string; 12 | municipio: string; 13 | nome_social: string; 14 | nome_comercial: string; 15 | pais: string; 16 | status: string; 17 | telefone: string; 18 | type: string; 19 | uf: string; 20 | valor_patrimonio_liquido: string; 21 | } 22 | -------------------------------------------------------------------------------- /src/routes/ibge/country.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { Country } from "../../types/ibge/country"; 3 | 4 | const endpoint = "/ibge/municipios/v1/"; 5 | 6 | /** 7 | * @deprecated Esta função está obsoleta. Use `ibge.city.getBy("UF")` no lugar. 8 | */ 9 | export const getBy = ( 10 | siglaUF: string, 11 | providers?: "dados-abertos-br" | "gov" | "wikipedia", 12 | ) => { 13 | let url = endpoint + siglaUF; 14 | if (providers) { 15 | url += "?providers=" + providers; 16 | } 17 | 18 | return get(url); 19 | }; 20 | -------------------------------------------------------------------------------- /src/types/cep.ts: -------------------------------------------------------------------------------- 1 | export interface CepV1 { 2 | cep: string; 3 | state: string; 4 | city: string; 5 | neighborhood: string; 6 | street: string; 7 | service: string; 8 | } 9 | 10 | export interface CepV2 { 11 | cep: string; 12 | state: string; 13 | city: string; 14 | neighborhood: string; 15 | street: string; 16 | service: string; 17 | location: Location; 18 | } 19 | 20 | interface Location { 21 | type: string; 22 | coordinates: Coordinates; 23 | } 24 | 25 | interface Coordinates { 26 | longitude: string; 27 | latitude: string; 28 | } 29 | -------------------------------------------------------------------------------- /src/routes/fipe/vehicles.ts: -------------------------------------------------------------------------------- 1 | import { get } from "../../service/api.service"; 2 | import { VehicleModel } from "../../types/fipe/model"; 3 | import { VehicleType } from "../../types/fipe/vehicle"; 4 | 5 | const endpoint = "/fipe/tabelas/v1/"; 6 | 7 | export const getBy = ( 8 | vehicleType: VehicleType, 9 | brandCode: number, 10 | tabela_referencia?: number, 11 | ) => { 12 | let url = `${endpoint}/${vehicleType}/${brandCode}`; 13 | if (tabela_referencia) { 14 | url += "?tabela_referencia" + tabela_referencia; 15 | } 16 | return get(url); 17 | }; 18 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [18.x, 20.x, 22.x, 23.x, 24.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v3 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | cache: 'npm' 29 | - run: npm ci 30 | - run: npm run build --if-present 31 | - run: npm test 32 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import * as bank from "./routes/bank"; 2 | import * as cep from "./routes/cep"; 3 | import * as cepV1 from "./routes/cepV1"; 4 | import * as cnpj from "./routes/cnpj"; 5 | import * as cvm from "./routes/cvm"; 6 | import * as ddd from "./routes/ddd"; 7 | import * as holidays from "./routes/holidays"; 8 | import * as cptec from "./routes/cptec"; 9 | import * as fipe from "./routes/fipe"; 10 | import * as ibge from "./routes/ibge"; 11 | import * as isbn from "./routes/isbn"; 12 | import * as ncm from "./routes/ncm"; 13 | import * as pix from "./routes/pix"; 14 | import * as registerBr from "./routes/registerBr"; 15 | import * as taxes from "./routes/taxes"; 16 | import * as exchange from "./routes/exchange"; 17 | import * as request from "./service/api.service"; 18 | 19 | const api = { 20 | request, 21 | bank, 22 | cep, 23 | cepV1, 24 | cnpj, 25 | cvm, 26 | cptec, 27 | ddd, 28 | holidays, 29 | fipe, 30 | ibge, 31 | isbn, 32 | ncm, 33 | pix, 34 | registerBr, 35 | taxes, 36 | exchange, 37 | }; 38 | 39 | export { 40 | api as default, 41 | request, 42 | bank, 43 | cep, 44 | cepV1, 45 | cnpj, 46 | cvm, 47 | cptec, 48 | ddd, 49 | holidays, 50 | fipe, 51 | ibge, 52 | isbn, 53 | ncm, 54 | pix, 55 | registerBr, 56 | taxes, 57 | exchange, 58 | }; 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "brasilapi-js", 3 | "version": "1.0.4", 4 | "description": "biblioteca em js para acessar Brasil Api", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "files": [ 8 | "/dist" 9 | ], 10 | "scripts": { 11 | "build": "npm run check && npm run lint && tsc", 12 | "test": "jest", 13 | "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"", 14 | "check": "prettier --ignore-path .gitignore -c \"**/*.+(js|ts|json)\"", 15 | "lint": "eslint .", 16 | "prepare": "husky" 17 | }, 18 | "author": "Willian Carlos Agostini", 19 | "license": "MIT", 20 | "dependencies": { 21 | "axios": "^1.9.0" 22 | }, 23 | "devDependencies": { 24 | "@eslint/js": "^9.28.0", 25 | "@swc/core": "^1.11.31", 26 | "@swc/jest": "^0.2.38", 27 | "@types/jest": "^29.5.14", 28 | "@typescript-eslint/eslint-plugin": "^8.34.0", 29 | "@typescript-eslint/parser": "^8.34.0", 30 | "eslint": "^9.28.0", 31 | "husky": "^9.1.7", 32 | "jest": "^29.7.0", 33 | "prettier": "^3.5.3", 34 | "rimraf": "^6.0.1", 35 | "ts-node": "^10.9.2", 36 | "typescript": "^5.8.3", 37 | "typescript-eslint": "^8.34.0" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/WillianAgostini/brasilapi-js/issues" 41 | }, 42 | "repository": { 43 | "type": "git", 44 | "url": "git://github.com/WillianAgostini/brasilapi-js.git" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/types/cnpj.ts: -------------------------------------------------------------------------------- 1 | export interface CNPJ { 2 | cnpj: string; 3 | identificador_matriz_filial: number; 4 | descricao_matriz_filial: string; 5 | razao_social: string; 6 | nome_fantasia: string; 7 | situacao_cadastral: number; 8 | descricao_situacao_cadastral: string; 9 | data_situacao_cadastral: string; 10 | motivo_situacao_cadastral: number; 11 | nome_cidade_exterior: unknown; 12 | codigo_natureza_juridica: number; 13 | data_inicio_atividade: string; 14 | cnae_fiscal: number; 15 | cnae_fiscal_descricao: string; 16 | descricao_tipo_logradouro: string; 17 | logradouro: string; 18 | numero: string; 19 | complemento: string; 20 | bairro: string; 21 | cep: number; 22 | uf: string; 23 | codigo_municipio: number; 24 | municipio: string; 25 | ddd_telefone_1: string; 26 | ddd_telefone_2: unknown; 27 | ddd_fax: unknown; 28 | qualificacao_do_responsavel: number; 29 | capital_social: number; 30 | porte: number; 31 | descricao_porte: string; 32 | opcao_pelo_simples: boolean; 33 | data_opcao_pelo_simples: unknown; 34 | data_exclusao_do_simples: unknown; 35 | opcao_pelo_mei: boolean; 36 | situacao_especial: unknown; 37 | data_situacao_especial: unknown; 38 | cnaes_secundarios: CnaesSecundario[]; 39 | qsa: Qsa[]; 40 | } 41 | 42 | interface CnaesSecundario { 43 | codigo: number; 44 | descricao: string; 45 | } 46 | 47 | interface Qsa { 48 | identificador_de_socio: number; 49 | nome_socio: string; 50 | cnpj_cpf_do_socio: string; 51 | codigo_qualificacao_socio: number; 52 | percentual_capital_social: number; 53 | data_entrada_sociedade: string; 54 | cpf_representante_legal: unknown; 55 | nome_representante_legal: unknown; 56 | codigo_qualificacao_representante_legal: unknown; 57 | } 58 | -------------------------------------------------------------------------------- /test/modules.spec.ts: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import cp from "child_process"; 3 | import util from "util"; 4 | import fs from "fs/promises"; 5 | 6 | const exec = util.promisify(cp.exec); 7 | 8 | describe("modules", () => { 9 | jest.setTimeout(10_000); 10 | 11 | beforeAll(async () => { 12 | const project = path.join(__dirname, ".."); 13 | await exec(`npm run build --prefix ${project}`, {}); 14 | }); 15 | 16 | const assertCode = ` 17 | assert.strictEqual(typeof api.bank.getAll, "function"); 18 | assert.strictEqual(typeof api.bank.getBy, "function"); 19 | assert.strictEqual(typeof api.cep.getBy, "function"); 20 | assert.strictEqual(typeof api.cepV1.getBy, "function"); 21 | assert.strictEqual(typeof api.cnpj.getBy, "function"); 22 | assert.strictEqual(typeof api.cptec.city.getBy, "function"); 23 | assert.strictEqual(typeof api.cptec.city.getAll, "function"); 24 | assert.strictEqual(typeof api.cptec.weather.airport.getBy, "function"); 25 | assert.strictEqual(typeof api.cptec.weather.capital.getAll, "function"); 26 | assert.strictEqual(typeof api.cptec.weather.forecast.getBy, "function"); 27 | assert.strictEqual(typeof api.cptec.weather.ocean.getBy, "function"); 28 | assert.strictEqual(typeof api.cvm.getAll, "function"); 29 | assert.strictEqual(typeof api.cvm.getBy, "function"); 30 | assert.strictEqual(typeof api.ddd.getBy, "function"); 31 | assert.strictEqual(typeof api.fipe.brands.getBy, "function"); 32 | assert.strictEqual(typeof api.fipe.price.getBy, "function"); 33 | assert.strictEqual(typeof api.fipe.tables.getAll, "function"); 34 | assert.strictEqual(typeof api.fipe.vehicles.getBy, "function"); 35 | assert.strictEqual(typeof api.holidays.getBy, "function"); 36 | assert.strictEqual(typeof api.ibge.country.getBy, "function"); 37 | assert.strictEqual(typeof api.ibge.city.getBy, "function"); 38 | assert.strictEqual(typeof api.ibge.state.getAll, "function"); 39 | assert.strictEqual(typeof api.ibge.state.getBy, "function"); 40 | assert.strictEqual(typeof api.isbn.getBy, "function"); 41 | assert.strictEqual(typeof api.ncm.getAll, "function"); 42 | assert.strictEqual(typeof api.ncm.getBy, "function"); 43 | assert.strictEqual(typeof api.pix.getAll, "function"); 44 | assert.strictEqual(typeof api.registerBr.getBy, "function"); 45 | assert.strictEqual(typeof api.taxes.getAll, "function"); 46 | assert.strictEqual(typeof api.taxes.getBy, "function"); 47 | `; 48 | 49 | const fileExt: Record = { 50 | cjs: "js", 51 | cts: "ts", 52 | mjs: "js", 53 | mts: "ts", 54 | ts: "ts", 55 | "ts-require": "ts", 56 | }; 57 | 58 | const importCode: Record = { 59 | cjs: 'const assert = require("assert");\nconst api = require("brasilapi-js");', 60 | cts: 'import assert from "assert";\nimport api from "brasilapi-js";', 61 | mjs: 'import assert from "assert";\nimport api from "brasilapi-js";', 62 | mts: 'import assert from "assert";\nimport api from "brasilapi-js";', 63 | ts: 'import assert from "assert";\nimport api from "brasilapi-js";', 64 | "ts-require": 65 | 'const assert = require("assert");\nconst api = require("brasilapi-js");', 66 | }; 67 | 68 | const runCommand: Record = { 69 | cjs: "node assert.js", 70 | cts: "npx tsx assert.ts", 71 | mjs: "node assert.js", 72 | mts: "npx tsx assert.ts", 73 | ts: "npx tsx assert.ts", 74 | "ts-require": "npx tsx assert.ts", 75 | }; 76 | 77 | describe.each(["cjs", "cts", "mjs", "mts", "ts", "ts-require"])( 78 | "modules", 79 | (type) => { 80 | const pkgPath = path.join(__dirname, `./module/${type}`); 81 | const testFile = path.join(pkgPath, `assert.${fileExt[type]}`); 82 | 83 | beforeAll(async () => { 84 | await fs.writeFile(testFile, `${importCode[type]}\n${assertCode}`); 85 | await exec("npm i --no-save --no-package-lock", { cwd: pkgPath }); 86 | }); 87 | 88 | afterAll(async () => { 89 | await exec("rimraf node_modules", { cwd: pkgPath }); 90 | await fs.rm(testFile); 91 | }); 92 | 93 | it(type, async () => { 94 | await exec(runCommand[type], { cwd: pkgPath }); 95 | }); 96 | }, 97 | ); 98 | }); 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Logo da BrasilAPI

2 | 3 |
4 |

5 | Uma lib para a API do BrasilAPI (para Node, Deno ou Bun) utilizando Javascript/Typescript 6 |

7 |
8 | 9 | # Introdução 10 | 11 | Esse SDK foi construído com o intuito de ser flexível, de forma que todos possam utilizar todas as features 12 | e versões da BrasilAPI. 13 | 14 | Você pode acessar a documentação oficial da BrasilAPI acessando esse [link](https://brasilapi.com.br/docs). 15 | 16 | # Instalação 17 | 18 | ```shell 19 | $ npm install brasilapi-js 20 | ``` 21 | 22 | # Documentação 23 | 24 | Documentação oficial da API com todas as chamadas poderão se encontradas [neste link](https://brasilapi.com.br/docs). 25 | 26 | 27 | # Utilização 28 | 29 | ## Node.js ou Bun 30 | 31 | ```js 32 | import api from "brasilapi-js"; 33 | ``` 34 | 35 | ## Deno 36 | 37 | ```js 38 | import api from "npm:brasilapi-js"; 39 | ``` 40 | 41 | ## Endpoints 42 | 43 | Abaixo você pode ver todos os endpoints disponíveis, por padrão, na biblioteca: 44 | 45 | ### Banks 46 | 47 | Buscando todos os bancos disponíveis na API. 48 | ```js 49 | const response = await api.bank.getAll(); 50 | ``` 51 | 52 | Buscando um banco específico pelo seu código. 53 | ```js 54 | const response = await api.bank.getBy(1); 55 | ``` 56 | 57 | ### CEP V1 58 | 59 | Buscando um CEP específico. 60 | 61 | ```js 62 | const response = await api.cepV1.getBy('01001000'); 63 | ``` 64 | 65 | ### CEP V2 66 | 67 | Buscando um CEP específico. 68 | 69 | ```js 70 | const response = await api.cep.getBy('01001000'); 71 | ``` 72 | 73 | ### CNPJ 74 | 75 | Buscando um CNPJ específico. 76 | 77 | ```js 78 | const response = await api.cnpj.getBy('00000000000191'); 79 | ``` 80 | 81 | ### Corretoras 82 | 83 | Buscando uma corretora específica pelo CNPJ. 84 | 85 | ```js 86 | const response = await api.cvm.getBy('76621457000185'); 87 | ``` 88 | 89 | Buscando todas as corretoras listadas pela CVM. 90 | 91 | ```js 92 | const response = await api.cvm.getAll(); 93 | ``` 94 | 95 | ### CPTEC 96 | 97 | Buscando uma cidade pelo nome. 98 | 99 | ```js 100 | const response = await api.cptec.city.getBy('São Paulo'); 101 | ``` 102 | 103 | Buscando todas as cidades disponíveis. 104 | 105 | ```js 106 | const response = await api.cptec.city.getAll(); 107 | ``` 108 | 109 | Buscando as informações meteorológicas em todas as capitais dos estados brasileiros. 110 | 111 | ```js 112 | const response = await api.cptec.weather.capital.getAll(); 113 | ``` 114 | 115 | Buscando as informações meteorológicas em um aeroporto específico através do seu código ICAO. 116 | 117 | ```js 118 | const response = await api.cptec.weather.airport.getBy('SBGR'); 119 | ``` 120 | 121 | Buscando as informações meteorológicas de uma cidade específica pelo seu código. 122 | 123 | ```js 124 | const response = await api.cptec.weather.forecast.getBy(999); 125 | ``` 126 | 127 | Buscando as informações meteorológicas de uma cidade específica no período de X dias. 128 | 129 | **Obs.:** O primeiro parâmetro se refere ao código da cidade e o segundo parâmetro refere-se a quantidade de dias. 130 | Lembrando que só é possível buscar informações entre 1 a 6 dias. 131 | 132 | ```js 133 | const response = await api.cptec.weather.forecast.getBy(999, 6); 134 | ``` 135 | 136 | Buscando a previsão oceânica em uma cidade específica. 137 | 138 | ```js 139 | const response = await api.cptec.weather.ocean.getBy(999); 140 | ``` 141 | 142 | Buscando a previsão oceânica em uma cidade específica no período de X dias. 143 | 144 | **Obs.:** O primeiro parâmetro se refere ao código da cidade e o segundo parâmetro refere-se a quantidade de dias. 145 | Lembrando que só é possível buscar informações entre 1 a 6 dias. 146 | 147 | ```js 148 | const response = await api.cptec.weather.ocean.getBy(999, 6); 149 | ``` 150 | 151 | ### DDD 152 | 153 | Buscando o estado e cidades que possuem determinado DDD. 154 | 155 | ```js 156 | const response = await api.ddd.getBy('77'); 157 | ``` 158 | 159 | ### Feriados 160 | 161 | Buscando todos os feriados nacionais em determinado ano. 162 | 163 | ```js 164 | const response = await api.holidays.getBy('2022'); 165 | ``` 166 | 167 | ### FIPE 168 | 169 | Buscando todas as marcas de veículos referente a um tipo de veículo. 170 | 171 | ```js 172 | const response = await api.fipe.brands.getBy('caminhoes'); 173 | ``` 174 | 175 | Buscando o preço de um veículo específico pelo seu código FIPE. 176 | 177 | ```js 178 | const response = await api.fipe.price.getBy('001004-9'); 179 | ``` 180 | 181 | Buscando as tabelas de referência existentes. 182 | 183 | ```js 184 | const response = await api.fipe.tables.getAll(); 185 | ``` 186 | 187 | Buscando os veículos de acordo com a marca e o tipo de veículo. 188 | 189 | ```js 190 | const response = await api.fipe.vehicles.getBy('carros', 36); 191 | ``` 192 | 193 | ### IBGE 194 | 195 | Buscando todos os municipios de um estado específico pela sua sigla. 196 | 197 | ```js 198 | const response = await api.ibge.city.getBy('SP'); 199 | ``` 200 | >ℹ️ A função city.getBy retorna a lista de municípios (cidades) do estado informado. 201 | >A função country.getBy permanece para compatibilidade, mas não representa corretamente esses dados 202 | >Buscando informações de um estado específico pela sua sigla. 203 | 204 | ```js 205 | const response = await api.ibge.state.getBy('BA'); 206 | ``` 207 | 208 | Buscando informações de todos os estados brasileiros. 209 | 210 | ```js 211 | const response = await api.ibge.state.getAll(); 212 | ``` 213 | 214 | Buscando informações de um estado específico pela sua sigla. 215 | 216 | ```js 217 | const response = await api.ibge.country.getBy('BA'); 218 | ``` 219 | > ⚠️ `api.ibge.country.getBy()` está obsoleto. 220 | > Recomendamos usar `api.ibge.city.getBy("UF")` para obter municípios de um estado. 221 | 222 | ### ISBN 223 | 224 | Buscando informações sobre um livro específico pelo seu código ISBN. 225 | 226 | ```js 227 | const response = await api.isbn.getBy('9788545702870'); 228 | ``` 229 | 230 | ### NCM 231 | 232 | Buscando informações sobre todos os NCMs. 233 | 234 | ```js 235 | const response = await api.ncm.getAll(); 236 | ``` 237 | 238 | Buscando informações sobre um NCM específico. 239 | 240 | ```js 241 | const response = await api.ncm.getBy('01012100'); 242 | ``` 243 | 244 | Buscando informações de um NCM a partir de um código ou descrição. 245 | 246 | ```js 247 | const response = await api.ncm.search('01012100'); 248 | ``` 249 | 250 | ### Pix 251 | 252 | Buscando informações de todos os participantes do PIX no dia atual ou anterior. 253 | 254 | ```js 255 | const response = await api.pix.getAll(); 256 | ``` 257 | 258 | ### Registro BR 259 | 260 | Buscando informações de um domínio específico. 261 | 262 | ```js 263 | const response = await api.registerBr.getBy('google.com'); 264 | ``` 265 | 266 | ### Taxas 267 | 268 | Buscando as taxas de juros e alguns índices oficiais do Brasil. 269 | 270 | ```js 271 | const response = await api.taxes.getAll(); 272 | ``` 273 | 274 | Buscando informações de uma taxa a partir do seu nome/sigla. 275 | 276 | ```js 277 | const response = await api.taxes.getBy('Selic'); 278 | ``` 279 | 280 | ### Cambio 281 | 282 | Retorna a lista de moedas que podem ser usadas como parâmetros para este conjunto de dados. 283 | 284 | ```js 285 | const response = await api.exchange.currency.getAll(); 286 | ``` 287 | 288 | Busca pelo câmbio do Real com outra moeda, em uma data específica. 289 | 290 | ```js 291 | const response = await api.exchange.rates.getBy('USD', '2025-02-13'); 292 | ``` 293 | 294 | ### Request 295 | 296 | Realizando uma chamada direta a qualquer URL da API BrasilAPI. 297 | 298 | ```js 299 | const response = await api.request.get('taxas/v1'); 300 | ``` 301 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs" /* Specify what module code is generated. */, 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./dist" /* Specify an output folder for all emitted files. */, 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 83 | 84 | /* Type Checking */ 85 | "strict": true /* Enable all strict type-checking options. */, 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | }, 109 | "include": ["src/**/*"], 110 | "exclude": ["**/*.spec.ts"] 111 | } 112 | --------------------------------------------------------------------------------