Skip to content

brianpgerson/zinc-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zinc-fetch

It's a super lightweight module for making requests to the zinc.io API. Basically, I wanted to drop a service into my app to handle zinc requests for me, and this seemed small and easy enough to be worth putting up as a package.

Install

npm install zinc-fetch --save

Usage

const ZincFetch = require('zinc-fetch')(YOUR_ZINC_API_KEY);

ZincService.product.getPrices(someItemId) // for an item at https://www.amazon.com/dp/1101904240, it's 1101904240
    .then(response => {
        response.offers.each(candidateOffer => {
            console.log(candidateOffer.price)
            // ===> 13.37
            console.log(candidateOffer.ship_price)
            // ===> 4.22
            // plus many more fields you can find in Zinc's docs.
        }
    });
});

See test cases for more examples.

API

product.getDetails(productId)

returns a Promise that resolves to a zinc product object or an error

product.getPrices(productId)

returns a Promise that resolves to a zinc product offers object or an error

order.create(data)

returns a Promise that resolves to a zinc order request_id that you can use to retrieve the order's status

order.retrieve(requestId)

returns a Promise that resolves to an order_response or error

Testing

Just run npm test from the root directory. Make sure your api key is available on process.env or set it first, like ZINC_KEY=12xxxxxxxYZ npm test.

License

MIT

Acknowledgement

I used Evan Tann's wrapper as a reference.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published