Node.js SDK

@storentia/sdk

Official Node.js SDK for the Storentia storefront API. Type-safe, GraphQL-powered, fully documented.

Install

shell
npm install @storentia/sdk

Setup

python
import { Storentia } from '@storentia/sdk'; const storentia = new Storentia({  clientId: 'your-client-id',  clientSecret: 'your-client-secret',});

Products

storentia.products.get(id: string)

Get a single product by id.

javascript
const product = await storentia.products.get('product-id');
storentia.products.list(opts)

List products, filtered by status and paginated.

javascript
const { data, pageInfo } = await storentia.products.list({  status: 'ACTIVE',  pagination: { page: 1, limit: 20 },});
storentia.products.create(input)

Create a product.

javascript
const newProduct = await storentia.products.create({  title: 'T-Shirt',  sellingPrice: 29.99,  originalPrice: 39.99,  sku: 'TSHIRT-001',});
storentia.products.update(id, input)

Update fields on a product.

shell
await storentia.products.update('product-id', {  sellingPrice: 34.99,  originalPrice: 44.99,});
storentia.products.delete(id)

Delete a product.

shell
await storentia.products.delete('product-id');

Variants

storentia.products.generateVariants(productId)

Generate the full variant matrix from a product's options.

javascript
const variants = await storentia.products.generateVariants('product-id');
storentia.products.createVariant(input)

Create a single variant explicitly.

javascript
const variant = await storentia.products.createVariant({  productId: 'product-id',  title: 'Red / Large',  sku: 'TSHIRT-001-RED-L',});
storentia.products.updateVariant(id, input)

Update a variant (e.g. stock).

shell
await storentia.products.updateVariant('variant-id', { stock: 50 });
storentia.products.deleteVariant(id)

Delete a variant.

shell
await storentia.products.deleteVariant('variant-id');

Options & values

storentia.products.addOption(input)

Add an option (e.g. "Color") to a product.

javascript
const option = await storentia.products.addOption({  productId: 'product-id',  name: 'Color',});
storentia.products.addOptionValue(input)

Add a value (e.g. "Red") to an option.

javascript
const value = await storentia.products.addOptionValue({  optionId: 'option-id',  value: 'Red',});
storentia.products.updateOption / deleteOptionValue

Update an option or delete an option value.

shell
await storentia.products.updateOption('option-id', { name: 'Colour' });await storentia.products.deleteOptionValue('value-id');

Collections

storentia.products.addToCollection(collectionId, productIds)

Add products to a collection.

shell
await storentia.products.addToCollection('collection-id', ['product-1', 'product-2']);
storentia.products.removeFromCollection(collectionId, productIds)

Remove products from a collection.

shell
await storentia.products.removeFromCollection('collection-id', ['product-1']);

Inventory

storentia.products.listInventory(opts)

List inventory across all products/variants for a store.

javascript
const { data, pageInfo } = await storentia.products.listInventory({  pagination: { page: 1, limit: 50 },});

Cart

Requires customer JWT authentication, not a store OAuth app token.

storentia.carts.get()

Get the current customer's cart.

javascript
const cart = await storentia.carts.get();
storentia.carts.addItem(input)

Add an item to the cart.

javascript
const item = await storentia.carts.addItem({  productId: 'product-id',  quantity: 1,});
storentia.carts.updateItem(input)

Update a cart item's quantity.

shell
await storentia.carts.updateItem({  cartItemId: 'cart-item-id',  quantity: 5,});
storentia.carts.removeItem(cartItemId)

Remove one item from the cart.

shell
await storentia.carts.removeItem('cart-item-id');
storentia.carts.clear()

Clear the entire cart.

shell
await storentia.carts.clear();

Customers

Passwordless email-code auth, the current customer's profile, and their saved addresses.

storentia.auth.sendAuthenticationEmail(email, publicStoreToken)

Emails a one-time login code to the customer. There is no password login.

javascript
const res = await storentia.auth.sendAuthenticationEmail('shopper@example.com', publicStoreToken);console.log(res.message);
storentia.auth.verifyAuthenticationEmail(email, code, publicStoreToken)

Exchanges the emailed code for a customer JWT and attaches it to this SDK instance.

javascript
const { id, email, name, token } = await storentia.auth.verifyAuthenticationEmail(  'shopper@example.com',  '123456',  publicStoreToken,);
storentia.auth.getMe()

Get the authenticated customer's profile. Requires a customer JWT (set by verifyAuthenticationEmail).

javascript
const me = await storentia.auth.getMe();
storentia.auth.updateMe(input)

Update the authenticated customer's own profile fields.

javascript
const me = await storentia.auth.updateMe({ name: 'Jane Doe' });
storentia.auth.getAddresses()

List the authenticated customer's saved addresses.

javascript
const addresses = await storentia.auth.getAddresses();
storentia.auth.addAddress(input)

Add a new address for the authenticated customer. Setting isDefault unsets any other default.

javascript
const address = await storentia.auth.addAddress({  line1: '221B Baker Street',  city: 'London',  postalCode: 'NW1 6XE',  country: 'GB',  isDefault: true,});
storentia.auth.updateAddress(id, input)

Update fields on one of the authenticated customer's addresses.

shell
await storentia.auth.updateAddress('address-id', { city: 'Manchester' });
storentia.auth.deleteAddress(id)

Remove an address.

shell
await storentia.auth.deleteAddress('address-id');
storentia.auth.setDefaultAddress(id)

Mark an address as the default, unsetting any other default.

javascript
const address = await storentia.auth.setDefaultAddress('address-id');
storentia.auth.logout()

Forget the customer JWT held by this SDK instance (local only). Use logoutGraphQL() to also invalidate it server-side.

shell
storentia.auth.logout();

Orders & checkout

Requires customer JWT authentication. Turns a cart into a paid order via whichever payment gateway the store has configured — Razorpay and Cashfree are both supported, and a store only ever returns the one it actually set up. Never assume a specific provider; branch on checkout.provider.

storentia.orders.paymentCapability(storeId)

Check whether the store can take payments before rendering a checkout button.

javascript
const { available, reason } = await storentia.orders.paymentCapability('store-id');if (!available) {  // show reason, hide checkout}
storentia.orders.createOrder(input)

Create an order from cart items and start a gateway checkout. Returns the order plus everything the browser needs to open the payment widget — none of it is a secret.

javascript
const { order, checkout } = await storentia.orders.createOrder({  currency: 'INR',  totalAmount: 199.99,  items: [    { productId: 'product-id', quantity: 2, price: 99.99 },  ],});// checkout: { provider, appId, gatewayOrderId, publicKey, amountMinor, currency, mode }
storentia.orders.confirmPayment(input)

Razorpay-specific: settles Razorpay's client-side handler callback against the order. The server re-verifies the signature with the merchant's own secret — nothing from the browser is trusted directly. Gateways without a client-side signature (Cashfree) don't use this call; use storentia.orders.syncPayment(orderId) instead.

javascript
if (checkout.provider === 'Razorpay') {  const { order } = await storentia.orders.confirmPayment({    orderId: order.id,    gatewayOrderId: response.razorpay_order_id,    gatewayPaymentId: response.razorpay_payment_id,    signature: response.razorpay_signature,  });}
storentia.orders.syncPayment(orderId)

For gateways whose browser SDK hands back no signed callback to verify (Cashfree). Settles the order by asking the gateway directly for its current status instead of trusting anything from the client.

javascript
if (checkout.provider === 'Cashfree') {  const { order } = await storentia.orders.syncPayment(order.id);}
storentia.orders.getOrder(orderId)

Get a single order, including current status and payment status. Poll this after confirmPayment()/syncPayment() — a gateway callback or reconciler pass can still lag behind either call.

javascript
const order = await storentia.orders.getOrder('order-id');
storentia.orders.getMyOrders(pagination?)

List the authenticated customer's own orders, scoped server-side from the JWT — no customerId to pass or spoof. Use this for a customer-facing "my orders" page; use getOrders()/getCustomerOrders() for merchant-side listing.

javascript
const myOrders = await storentia.orders.getMyOrders({ page: 1, limit: 20 });
storentia.orders.getOrders(pagination?, storeId?)

List orders. Returns a plain array — there is no pageInfo envelope on this field.

javascript
const orders = await storentia.orders.getOrders({ page: 1, limit: 20 });
storentia.orders.getCustomerOrders(customerId, pagination?, storeId?)

List a single customer's orders.

javascript
const orders = await storentia.orders.getCustomerOrders('customer-id');
storentia.orders.cancelOrder(orderId)

Cancel an order.

shell
await storentia.orders.cancelOrder('order-id');

Blog posts & pages

storentia.blogs.get / list / create / update / delete

Full CRUD for blog posts.

javascript
const post = await storentia.blogs.get('post-id');const { data, pageInfo } = await storentia.blogs.list({ pagination: { limit: 10 } });const newPost = await storentia.blogs.create({ title: 'Hello', content: '...' });await storentia.blogs.update('post-id', { title: 'Updated' });await storentia.blogs.delete('post-id');
storentia.pages.get / list / create / update / delete

Full CRUD for static pages.

javascript
const page = await storentia.pages.get('page-id');const { data, pageInfo } = await storentia.pages.list();const newPage = await storentia.pages.create({ pageTitle: 'About', content: '...' });await storentia.pages.update('page-id', { pageTitle: 'Updated' });await storentia.pages.delete('page-id');

Error handling

ApiError

Every failed call throws an ApiError with a statusCode and message.

python
import { ApiError } from '@storentia/sdk'; try {  const product = await storentia.products.get('invalid-id');} catch (err) {  if (err instanceof ApiError) {    console.error(`${err.statusCode}: ${err.message}`);  }}

Authentication & config

new Storentia({ clientId, clientSecret, timeout? })

OAuth2 client-credentials auth. Tokens auto-refresh before expiry.

javascript
const storentia = new Storentia({  clientId: string,      // Required  clientSecret: string,  // Required  timeout: 30000,        // Optional, milliseconds});
storentia.setAccessToken(token)

Override the SDK's token with a pre-obtained one — useful for customer-session flows.

shell
storentia.setAccessToken('pre-obtained-token');