Git Product home page Git Product logo

barcodelookup's Introduction

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

barcodelookup's People

Contributors

evscott avatar robincsamuel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.