Node.js API Client

This guide will get you all set up with our Node.js API Client, ready to integrate pricing, payments, authentication and more into your storefront.

The client is intended to be used for customer facing applications, with built-in security token handling including automatic refreshing of access tokens.

Getting started

Start by adding the package to your project

npm install @moonbase.sh/storefront-api --save

Now you're ready to instantiate the client itself:

import { MoonbaseClient } from '@moonbase.sh/storefront-api'

const client = new MoonbaseClient({
    endpoint: 'https://{YOUR-ACCOUNT-ID}.moonbase.sh',
});

Endpoint collections

The client exposes a number of endpoint collections:

  • Identity - For all authentication concerns
  • Inventory - For getting customer inventory of licenses & products
  • Orders - For handling order & cart contents
  • Storefront - For getting storefront products and bundles
  • Vouchers - For redeeming vouchers

All endpoint collections come with TypeScript types that explain the models.

Was this page helpful?