Skip to content

Simple API client for the BigCommerce Management API

Notifications You must be signed in to change notification settings

classyllama/bigcommerce-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bigcommerce-client

Simple API client for the BigCommerce Management API

Installation

npm i bigcommerce-client

Usage

const bc_client = require('bigcommerce-client')
const store = new bc_client('storeHash', 'authToken')

Get a Resource

async function getFromSKU(sku){
    return await store.get('v3/catalog/products', {sku})
}

Get All Resources

async function getOutOfStock(sku){
    return await store.getAll('v3/catalog/products', {inventory_level:0})
}

Paginate All Resources

async function updateOutOfStock(sku){
    await store.paginate('v3/catalog/products', async (products)=>{
        await store.put('v3/catalog/products', products.map((product)=>{
            product.inventory_level = 1
            return product
        }))
    }, {limit:10, inventory_level:0, include_fields:'inventory_level'})
}

Create a Resource

async function createDigitalProduct(name, price){
    return (await store.post('v3/catalog/products', {name, price, type:'digital', weight:0})).id
}

Update Resource

async function changePrice(id, price){
    try {
        await store.put(`v3/catalog/products/${id}`, {price}))
    } catch (new Error('ID not found'))
}

Delete a Resource

async function deleteProduct(id){
    try {
        await store.delete(`v3/catalog/products/${id}`))
    } catch (new Error('ID not found'))
}

Delete All Resources

async function deleteAllProducts(){
    await store.deleteAll(`v3/catalog/products`))
}

About

Simple API client for the BigCommerce Management API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%