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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dbase-sdk

v0.1.0

Published

Unofficial TypeScript SDK for the DBase API: CPF, CNPJ, phone, CEP, name, e-mail and company prospecting lookups for Brazil

Readme

dbase-sdk

TypeScript client for the DBase API: CPF, CNPJ, phone, CEP, name and e-mail lookups, and company prospecting from the Receita Federal base, for Brazil. Unofficial, not made by DBase.

npm install dbase-sdk
# or
bun add dbase-sdk

The same code is also published as @gusnips/dbase. The dbase name on npm is a different package, by someone else.

First call

import { DbaseClient } from "dbase-sdk";

const dbase = new DbaseClient("YOUR_TOKEN");

const company = await dbase.cnpj({ cnpj: "00000000000191" });

Before it works, do two things:

  1. Get your token in the restricted area of dbase.com.br.
  2. Have your server's IP allowlisted. DBase only answers calls from IPs on its list, and its message asks you to send the IPv4 or IPv6 address to its support. Until then every call fails with code 003.

Keep the token on your server. Never ship it to a browser.

Finding the method you need

The API has one endpoint, and the consulta field picks the lookup. Each consulta is one method:

| consulta | In the SDK | | ------------ | --------------------------------------- | | cpf | dbase.cpf({ cpf }) | | cnpj | dbase.cnpj({ cnpj, versao }) | | telefone | dbase.telefone({ telefone }) | | cep | dbase.cep({ cep, numero_inicial }) | | nome | dbase.nome({ nome }) | | email | dbase.email({ email }) | | prospeccao | dbase.prospeccao({ uf, cidade, ... }) |

Params keep the API's own names, so what you read in DBase's swagger is what you type. versao (1 or 2) picks the version of the CNPJ answer.

Prospecting companies

const page = await dbase.prospeccao({
  uf: "ES",
  cidade: "VITORIA",
  cnae: "6201501",
  so_matriz: 1,
  pagina: 1,
});

console.log(page.total, page.total_paginas, page.empresas.length);

It needs the "Prospecção de Empresas" product on your account. A page holds 50 companies, up to page 40. DBase bills one search once, and paging through the same search is not billed again for 60 minutes.

Errors

Every failure throws a DbaseError. DBase reports a failure in the body as { status: false, codigo, msg }, and sometimes sends it with HTTP 200, so the client reads the body and not only the status:

import { DbaseError } from "dbase-sdk";

try {
  await dbase.cep({ cep: "29010001" });
} catch (error) {
  if (error instanceof DbaseError) {
    console.log(error.status); // HTTP status, or 0 if no answer came back
    console.log(error.code); // DBase's codigo, for example "003"
    console.log(error.message); // DBase's msg, in Portuguese
  }
}

Codes seen so far (the messages are DBase's):

| Code | HTTP | DBase says | | ----- | ---- | ------------------------------------------ | | 003 | 200 | Seu ip não está liberado para acesso a api | | 004 | 400 | Campo token faltando ou inválido |

Cost and limits

DBase bills by search, and which lookups it bills depends on your plan, so check your account before a loop. The SDK never retries a call: a retry could bill a second time, and a call that timed out may already have been billed. If you want retries, add them for the errors you know are safe.

Options

new DbaseClient({
  token: "...",
  baseUrl: "https://app.dbase.com.br", // default
  timeout: 60_000, // milliseconds, default
  fetch: myFetch, // replaces the global fetch
});

About the types

Request types follow DBase's swagger. The one answer type shaped by the docs is the envelope of prospeccao. Every other successful answer is typed as a plain object (Record<string, unknown>), because DBase's swagger does not describe the answers and none has been captured yet. Check a field before you read it.

Not included: DBase's web panel (the PHPSESSID login). That route reads HTML and needs a session kept alive; this SDK only speaks the API.

If a real answer does not fit, open an issue with the call and the field.

License

MIT