@agnostack/bigcommerce-request
v1.0.0
Published
Please contact agnoStack via [email protected] for any questions
Downloads
3
Maintainers
Readme
@agnostack/bigcommerce-request
🎮 Minimal BigCommerce API request library for Node
Installation
yarn add @agnostack/bigcommerce-request # npm install @agnostack/bigcommerce-request
Quickstart (OAuth)
const { createClient } = require('@agnostack/bigcommerce-request');
// import { createClient } from '@agnostack/bigcommerce-request'
const bigcommerce = new createClient({
store_id: '...', // BigCommerce Store Name.
client_id: '...', // BigCommercie Client Name.
access_token: '...', // BigCommerce OAuth token.
});
bigcommerce
.get('v3/catalog/products')
.then(console.log)
.catch(console.error);
bigcommerce
.post('v3/customers', {
first_name: 'Jane'
last_name: 'Doe',
email: '[email protected]'
})
.then(console.log)
.catch(console.error);
bigcommerce
.put('v3/customers', {
id: 1,
company: 'Company Name',
first_name: 'Jane'
last_name: 'Doe',
email: '[email protected]',
phone: '123456788900'
})
.then(console.log)
.catch(console.error);
Kitchen sink
const bigcommerce = new createClient({
store_id: '...',
client_id: '...',
access_token: '...',
headers: {
// ...
}
});
Custom headers per request
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.