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

api-estadosdobrasil

v1.0.7

Published

A better way to format and get details about your variables

Downloads

24

Readme

API - Estados do Brasil

The aim is to assist in querying Brazilian states and their cities, whether for use in user registration forms or even for filtering data in tracking tables or similar generic tasks.

We intentionally keep it simple by not providing information such as ZIP codes, street names, or neighborhood names.

To Install

Install the package api-estadosdobrasil in your project.

npm install api-estadosdobrasil

yarn add api-estadosdobrasil

bun add api-estadosdobrasil

How to consume?

There are several ways you can consume this API. You can simply:

Install the dependency and import Brasil, then assign it to a variable in your project.

import Brasil from 'api-estadosdobrasil'

const myEstados = Brasil.estados // To get all state information
const myCidades = Brasil.cidades // To get all city information

And how do I specifically get information about the city of Campinas, located in the interior of São Paulo, if I want to consume it?

import Brasil from 'api-estadosdobrasil'

const Campinas = Brasil.cidades.siglaEstado['SP'].nome['Campinas']

To consume only the name of the state of São Paulo:

import Brasil from 'api-estadosdobrasil'

const SP = Brasil.estados.id['SP'].nome

Of course, you can filter and customize this according to your preferences.

Another way is to fetch directly from the route or from the repository file.

  1. Fetch from the route and consume from there.
    fetch("https://api.github.com/users/Yagasaki7K")
        .then(response => response.json())
        .then(data => {
            setDataAPI(data) // If you're using a State of React for example.
            let data = JSON.stringify(data) // If you're using a variable.
        });

2.1 Fetch directly from the file in the repository - less recommended.

    fetch("https://github.com/Yagasaki7K/api-estadosdobrasil/blob/main/database.json")
        .then(response => response.text())
        .then(data => {
            setDataAPI(data) // If you're using a State of React for example.
            let data = JSON.stringify(data) // If you're using a variable.
        });

How to Contribute?

If you have ideas, you can contribute to the repository on GitHub, following the basic concepts of a pull request - we don't have a specific template for this.

Tests

bun test v1.1.4 (fbe2fe0c)

index.test.ts:
✓ Brasil object should be imported correctly [1.04ms]
✓ Should have states in the list of states [0.03ms]
✓ Should have cities in the list of cities [0.03ms]
✓ Campinas should be in the list of cities of São Paulo [1.20ms]
✓ São Paulo state should be in the list of states [0.03ms]

5 pass