@commonninja/node-sdk
v1.1.37
Published
Common Ninja SDK for NodeJS
Downloads
747
Readme
@commonninja/node-sdk
Installation
// NPM
npm i @commonninja/node-sdk
// Yarn
yarn add @commonninja/node-sdk
Usage
import { CommonNinja } from '@commonninja/node-sdk';
const client = new CommonNinja({
appId: process.env.COMMONNINJA_APP_ID,
appSecret: process.env.COMMONNINJA_APP_SECRET,
accessToken: req.query.token,
env: CommonNinja.envs.production,
});
// Get shop products, filter by category
const { data, success, message } = await client.ecommerce.getProducts({
category: '1',
});
// Get shop orders
const { data, success, message } = await client.ecommerce.getOrders();
// Get shop customers with pagination parameters
const { data, success, message } = await client.ecommerce.getCustomers({
limit: 5,
page: 1,
});
// Get user details
const { data, success, message } = await client.user.getDetails();
// Get connect to platform screen url
const connectUrl = client.auth.getConnectUrl();
// Get Shopify authentication url
const redirectUrl = client.auth.getAuthenticationUrl('shopify');
// Validate an incoming webhook message from Common Ninja
client.webhooks.validateWebhook(req);
Learn more about the different APIs in our official docs.