Socket
Book a DemoInstallSign in
Socket

bigcommerce-store-api

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bigcommerce-store-api

BigCommerce Store API Client

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

bigcommerce-store-api

This is a simple BigCommerce API client library written in Typescript, it allows developers to interact with the BigCommerce platform. By using this library, developers can easily integrate their applications with BigCommerce stores, enabling them to access and manipulate store data such as products, orders, customers, and more.

Getting Started

  • Installation
  • Basic Usage

Installation

npm install bigcommerce-store-api

Basic Usage

import BigCommerceStoreApi from 'bigcommerce-store-api';

const apiClient = new BigCommerceStoreApi({
    storeHash: 'storeHash',
    accessToken: 'accessToken',
});

const response = await apiClient.v3.products.getProducts({
    limit: 10,
});

if (response.status === 'success') {
    console.log(response.data);
} else {
    console.log(response.errors);
}

const responseProduct = await apiClient.v3.products.getProduct(1234);

if (responseProduct.status === 'success') {
    console.log(responseProduct.data);
} else {
    console.log(responseProduct.errors);
}

Low level API

If you need to directly call the get, post put delete methods with a custom URL and custom parameter, you can get the apiClient.request object and call the corresponding method. For example:

apiClient.request.put({
    path: 'v3/catalog/products',
    contentType: 'application/json',
    body: [
        { id: 123, name: 'New Product Name' },
        { id: 456, name: 'New Product Name' }
    ],
    query: {
        include_fields: ['name'],
    },
});

Error Handling

bigcommerce-store-api will not throw an error, instead it return error details in response

const response = await apiClient.v3.products.getProduct(1234);

if (response.status === 'error') {
    console.log(response.errors);
}

But for program safety, I recommend implementing a try catch to ensure your code is not interrupted by a library bug. For example:

const response = await productApi
    .getProducts()
    .catch(error => {
        console.log(error);
    });

if (response) {
    console.log(response);
}

// or
try {
    const response = await productApi.getProducts();
    console.log(response);
} catch (error) {
    console.log(error);
}

Keywords

bigcommerce

FAQs

Package last updated on 02 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.