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

barcodelookup

v1.0.6

Published

A lightweight importable Node.js package that can be used to resolve barcode data

Downloads

40

Readme

David

barcodelookup

An installable Node.js package that easily handles barcodelookup requests.

Prerequisites

  1. Ensure that you have a valid API key provided by barcodelookup.

  2. Ensure that Node.js and npm is installed on your machine.

node --version // v11.14.0
npm --version // 6.9.0

Installing

Inside of your projects root directory, install the barcodelookup package using npm.

npm install barcodelookup

How to use

Inside any file of your project, import the barcodelookup package from node_modules.

const bc = require('barcodelookup');

To make a request, call either lookup or rateLimits and provide the necessary arguments in a key-value object format to fulfill the request.

bc.lookup({
        key: 'your api key',
        barcode: 'some barcode to lookup'
    });

bc.rateLimits({
        key: 'your api key'
    });

Functions available

lookup

lookup uses destructured parameters to accept arguments marked by the keys which barcodelookup accepts: i.e. barcode, mpn, asin, key, etc.

lookup({ barcode: barcode, mpn: mpn, asin: asin, productName: productName, category: category, 
            search: search, page: page, geo: geo, formatted: formatted, key: key })

lookup returns an object as a promise. The object will contain a status code and either a data packet of products or an error message.

{ statusCode: 200, data: { products: [ [Object] ] } }
...
{ statusCode: 403, data: 'Forbidden' }
...
{ statusCode: 404, data: 'Not Found' }
...
{ statusCode: 429, data: 'Too Many Requests' }

Example product object:

{ products:
   [ { barcode_number: '063652852403',
       barcode_type: 'UPC',
       barcode_formats: 'UPC 063652852403, EAN 0063652852403',
       mpn: '063652852403',
       model: '',
       asin: '',
       product_name: 'Crayola 24 Ultra Clean Washable Markers by Crayola',
       title: 'Crayola 24 Ultra Clean Washable Markers by Crayola',
       category:
        'Sporting Goods > Outdoor Recreation > Golf > Golf Ball Markers',
       manufacturer: 'Crayola',
       brand: 'Crayola',
       label: '',
       author: '',
       publisher: '',
       artist: '',
       actor: '',
       director: '',
       studio: '',
       genre: '',
       audience_rating: '',
       ingredients: '',
       nutrition_facts: '',
       color: '',
       format: '',
       package_quantity: '',
       size: '',
       length: '',
       width: '',
       height: '',
       weight: '',
       release_date: '',
       description:
        'Crayola Washable markers are now Ultra Washable! Washable from skin, clothing and now from walls! Washability you can trust from the world's most washable marker!Markers that deliver superb colour coverage and lay down. The markers come in various degrees of washability and a wide variety of marker tips.Fine tip for outlining, writing and drawingInk washes easily from skin and fabricsMachine washable.',
       features: [],
       images: [Array],
       stores: [Array],
       reviews: [] } ] }

See the official barcodelookup api documentation for more information on returned fields.

rateLimits

rateLimits queries the barcodelookup account registry to return account details pertaining to an api-key.

rateLimits({ key: key })

rateLimits returns an object as a promise. The object will contain a status code and either a data packet of account information or an error message.

{ statusCode: 200,
  data:
   { allowed_calls_per_month: '50',
     remaining_calls_per_month: '48',
     allowed_calls_per_minute: '50',
     remaining_calls_per_minute: '49' } }
...
{ statusCode: 403, data: 'Forbidden' }
...

See the official barcodelookup api documentation for more information on returned fields.

Built With

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details