@agnostack/bigcommerce-request
🎮 Minimal BigCommerce API request library for Node
Installation
yarn add @agnostack/bigcommerce-request
Quickstart (OAuth)
const { createClient } = require('@agnostack/bigcommerce-request');
const bigcommerce = new createClient({
store_id: '...',
client_id: '...',
access_token: '...',
});
bigcommerce
.get('v3/catalog/products')
.then(console.log)
.catch(console.error);
bigcommerce
.post('v3/customers', {
first_name: 'Jane'
last_name: 'Doe',
email: 'johndoe@email.com'
})
.then(console.log)
.catch(console.error);
bigcommerce
.put('v3/customers', {
id: 1,
company: 'Company Name',
first_name: 'Jane'
last_name: 'Doe',
email: 'johndoe@email.com',
phone: '123456788900'
})
.then(console.log)
.catch(console.error);
Kitchen sink
const bigcommerce = new createClient({
store_id: '...',
client_id: '...',
access_token: '...',
headers: {
}
});
The API provides you the ability to send various request headers that change the way data is stored or retrieved.
By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type
header as an additional argument to get
, patch
, post
, put
and delete
.
Note: If you add the Content-Type
custom header to patch
, post
, put
or delete
you will need to encode data
yourself.
const bigcommerce = new createClient({
store_id: '...',
client_id: '...',
access_token: '...'
});
const headers = {
'X-My-Header': 'custom'
};
bigcommerce
.get('v3/catalog/products', headers)
.then(console.log)
.catch(console.error);
Contact Adam Grohs @ agnoStack for any questions.