canopy-node
v0.0.8
Published
A Node.js library for the Canopy product catalog API.
Readme
Canopy Node
A Node.js library for the Canopy product catalog API.
Installation
npm install canopy-nodeRequirements
- Node.js 12 or higher
- Axios 1.7.7 or higher
Usage
Import the package and initialize the Client
The library needs to be configured with your account's secret key which is available via the Canopy Website. Set canopy-node.apiKey to its value:
const CanopyNode = require('canopy-node')
const apiKey = 'public_3ZnvnqEShnANvujDeoUtwdS8';
// to test the api, you can use the public test API key
const canopy = new CanopyNode(apiKey);
Adding a product to the catalog
// define a new product object
const newProduct = {
name: 'Leafy Weather Agent',
company: 'Canopy',
description: 'A software tool for finding the best foliage',
}
// add product to the Canopy product catalog
const product = await canopy.createProduct(newProduct)Querying the product catalog
// get products by userId (store/merchant/seller)
const products = await canopy.getProducts({ userId: 'user_2nqjq9cTCW8SsYEeqm80G1ES3Z9' })
// get products by name
const products = await canopy.getProducts({ name: 'Canopy Product' })
// get products by company
const products = await canopy.getProducts({ company: 'Canopy Co' })
// get products by description
const products = await canopy.getProducts({ description: 'A Great New Product' })
// get products by id
const products = await canopy.getProducts({ id: 'b747da55-ea38-431a-b383-29f49d079caa' })
