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

@geobarriers/gbapi

v1.1.1

Published

Front end api for geo barriers

Readme

Geobarriers Javascript Library [Client Side Only]

Version Downloads

The Geobarriers Javascript library provides convenient access to the Geobarriers API from applications written in client-side JavaScript.

The REST API that allows developers to easily integrate zipcode, county, and state boundaries into websites, Google Maps, GIS systems or any client applications that can consume GeoJson.

Documentation

See the API docs.

Installation

Install the package with:

npm install @geobarriers/gbapi --save

// or using yarn
yarn add @geobarriers/gbapi

Usage

The library needs to be configured with your api key on instantiation like below. The map property is optional if you plan on autoloading geojson onto a map.

import GBApi from '@geobarriers/gbapi';

//.. do google map stuff (if you want)

const gb = new GBApi({ key: 'your-api-key', map });
gb.zip(28203).getGeoJson()
    .then(geojson => {
        // ...do geojson things 
    })
    .catch(error => {
        // ...handle errors
    });
    

Or using Async/Await:

import GBApi from '@geobarriers/gbapi';

const gb = new GBApi({ key: 'your-api-key' });

try {
    const geojson = await gb.zip(28203).getGeoJson();
    //... do geojson things
} catch (error) {
    // ...handle errors
}

Search Types

There are currently 3 search types:

  • zip code
  • county
  • state
  • fsa (Canada)

Zip Search

Zip search type can take a string or array of zip codes.


const gb = new GBApi({ key: 'your-api-key' });
try {
    const geojson = await gb.zip([28203, 28208, 28202]).getGeoJson();
    //... do geojson things
} catch (error) {
    // ...handle errors
}

County Search

County search type can take a string or array of counties and a state abbreviation.


const gb = new GBApi({ key: 'your-api-key' });
try {
    const geojson = await gb.county({ 
        county: 'Union',
        state: 'NC' 
    }).getGeoJson();

    //... or multiple counties 
    const geojson = await gb.county([
        { county: 'Union', state: 'NC' },
        { county: 'York', state: 'SC' }
    ]).getGeoJson();


    //... do geojson things
} catch (error) {
    // ...handle errors
}

State Search

State search type can take a string or array of states abbreviation.


const gb = new GBApi({ key: 'your-api-key' });
try {
    const geojson = await gb.county(['Florida', 'Georgia']).getGeoJson();
    //... do geojson things
} catch (error) {
    // ...handle errors
}

Fsa Search

Fsa search type can take a string or array of fsa codes.


const gb = new GBApi({ key: 'your-api-key' });
try {
    const geojson = await gb.fsa(["A0A", "A0B"]).getGeoJson();
    //... do geojson things
} catch (error) {
    // ...handle errors
}

Using Google Maps

The Geobarriers library provides a method to load geojson data directly onto the map. Skipping a whole step. The only parameter is a boolean to clear all current features on the map. Defaults to true.


//... google map stuff 

const gb = new GBApi({ key: 'your-api-key', map }); // <- must init with map object
try {
    await gb.zip([28208, 28203]).loadGeoJson(true);
    
} catch (error) {
    // ...handle errors
}

You can also just pass the map into the addGeoJson method as well.


//... google map stuff 

const gb = new GBApi({ key: 'your-api-key' }); //<- no map provided at init
try {
    const geoJson = await gb.zip([28208, 28203]).getGeoJson();
    gb.addGeoJson(geoJson, map, true); //<- true argument will clear out previous data layer on your map
} catch (error) {
    // ...handle errors
}

Response Object

{
    "data": {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": {
                    //...
                },
                "geometry": {
                    "type": "MultiPolygon",
                    "coordinates": [
                        //...
                    ]
                }
            }
        ]
    }
}

TODO

  • Need to write some test
  • Need to provide browser support polyfill.io
  • Add Canada postal codes FSA & LDU