Registry / http-networking / ordercloud-javascript-sdk

ordercloud-javascript-sdk

JSON →
library12.0.0jsnpmunverified

The OrderCloud JavaScript SDK is a modern client library designed for building robust solutions targeting the OrderCloud eCommerce API. It significantly enhances developer productivity and reduces common errors by providing a full feature parity with the underlying API, comprehensive built-in TypeScript support, and an auto-generated API reference. The SDK operates seamlessly in both browser and Node.js environments and offers an ESM module for bundlers that support tree shaking, enabling leaner project bundles. The current stable version is 12.0.0, with minor releases occurring frequently, indicating an actively maintained project. A key differentiator is its deep integration with the OrderCloud platform, offering dedicated functionalities for authentication, advanced filtering, and impersonation. It explicitly handles `axios` as a peer dependency to prevent potential version conflicts and avoid unnecessary bundle bloat.

npm install ordercloud-javascript-sdk
INSTALL
IMPORT
SIG · ORDERCLOUD-JAVASCR
O
ordercloud-javascript-sdk
http-networkingjavascriptv12.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Products
import { Products } from 'ordercloud-javascript-sdk';
const Products = require('ordercloud-javascript-sdk').Products;
Recommended for browser environments to enable tree shaking, importing only the necessary API resource modules.
Auth, Tokens
import { Auth, Tokens } from 'ordercloud-javascript-sdk';
import OrderCloudSDK from 'ordercloud-javascript-sdk'; // Auth is not a default export
Accesses authentication methods and token utilities. This SDK uses named exports exclusively for its modules.
OrderCloudSDK (full object)
const OrderCloudSDK = require('ordercloud-javascript-sdk');
import OrderCloudSDK from 'ordercloud-javascript-sdk'; // No default export for the entire SDK object
Standard CommonJS import for Node.js environments or projects not using ESM. All resources are accessible via `OrderCloudSDK.ResourceName`.

Demonstrates how to authenticate with the OrderCloud API using a username/password flow, store the access token for subsequent API calls, and handles potential errors during the authentication process.

import { Auth, Tokens } from 'ordercloud-javascript-sdk'; // These should ideally come from environment variables or a secure configuration store. // Using process.env.VAR_NAME ?? '' for illustration, replace with actual secure methods in production. const username = process.env.ORDERCLOUD_USERNAME ?? 'YOUR_USERNAME'; const password = process.env.ORDERCLOUD_PASSWORD ?? 'YOUR_PASSWORD'; const clientID = process.env.ORDERCLOUD_CLIENT_ID ?? 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; // Sign up for free at portal.ordercloud.io/register const scope = ['FullAccess']; // Array of roles, e.g., ['FullAccess', 'BuyerAdmin', 'MeAdmin'] async function authenticateAndLogToken() { try { const response = await Auth.Login(username, password, clientID, scope); const token = response.access_token; Tokens.SetAccessToken(token); // Set the token globally for subsequent API calls console.log('Successfully authenticated!'); console.log('Access Token:', token); // Example: After successful login, you can make other API calls // import { Products } from 'ordercloud-javascript-sdk'; // const products = await Products.List(); // console.log('First 20 products:', products.Items.map(p => p.Name)); } catch (error: any) { console.error('Authentication failed:', error.message); if (error.response) { console.error('API Error Response:', error.response.data); } } } authenticateAndLogToken();
Debug
Known issues
breakingMajor versions (e.g., v12.0.0) often introduce breaking changes. It is crucial to consult the `MIGRATION_GUIDE.md` for specific instructions when upgrading from older versions.
fix
Always review the `MIGRATION_GUIDE.md` document in the package's GitHub repository or documentation when upgrading to a new major version to understand and apply necessary code changes.
affects: <12.0.0
gotchaThe `axios` library is a peer dependency and is not automatically installed with the SDK. Failure to install `axios` separately will lead to runtime errors when making API calls.
fix
Ensure `axios` is installed in your project: `npm install axios` or `yarn add axios`.
affects: >=1.0.0
gotchaThe SDK relies exclusively on named exports for its modules. Attempting to use a default import will result in `undefined` or runtime errors.
fix
Always use named imports (e.g., `import { Auth } from 'ordercloud-javascript-sdk';`) for ESM, or access properties on the `require`'d object (e.g., `OrderCloudSDK.Auth`) for CJS.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'axios' or its corresponding type declarations.
The `axios` library, a required peer dependency, is not installed in the project.
fix
Install `axios` using your package manager: `npm install axios` or `yarn add axios`.
TypeError: OrderCloudSDK.Auth.Login is not a function
This error typically occurs if `Auth` was not correctly imported or accessed. Common causes include trying to use `OrderCloudSDK.Auth` after a named ESM import like `import { Auth } from 'ordercloud-javascript-sdk';` or attempting to destructure `Auth` from a CommonJS `require` call without first getting the main object.
fix
For ESM, ensure you use `import { Auth } from 'ordercloud-javascript-sdk';` and then directly call `Auth.Login(...)`. For CJS, use `const OrderCloudSDK = require('ordercloud-javascript-sdk');` and then call `OrderCloudSDK.Auth.Login(...)`.
Upgrade
Version history
12.0.0latest on npm
Audit
Dependencies
axiosrequiredRequired peer dependency for all HTTP requests made by the SDK. Must be installed separately to prevent multiple axios versions in a project.
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
ordercloud-javascript-sdk — npm install ordercloud-javascript-sdk · libregistry