npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

platform-sdk-node

v0.10.8

Published

A node sdk for Platform API

Readme

Platform SDK for NodeJs

Install

npm i --save git+ssh://[email protected]:chaordic/platform-sdk-node.git

Usage Examples

Constructor

const Platform = require('platform-sdk-node');

const platformClient = new Platform({
  apis: { // overrides default client configs
    clients: {
      // overrides host for clients only
      host: 'https://clients.chaordicsystems.com',
    },
  },
  // default host
  host: 'https://platform.chaordicsystems.com',
  // default authorization, can be a string or an object, with usermame/pass
  authorization: '<platform basic auth>',
  // default timeout, can be overridden, both within api configs, and in
  // specific methods
  requestTimeout: 10000,
  // an optional interceptor function for endpoint calls, you can then
  // manipulate the promise. This function should return the promise's result
  // interceptor: (promise, clientName) => promise,
  interceptor: async (promise, clientName) => {
    // at this point the promise for clientName just begun
    // we could for example measure the RT of the request here
    const start = process.hrtime();

    try {
      const result = await promise;
      // at this point, the promise resolved
      // it's important to return the promises result
      return result;
    } catch (err) {
      // the promise rejected
      console.log('err', err);

      // we want the method caller itself to handle the errors, so we throw here
      throw err;
    } finally {
      // this code will run regardless of the promise resolving or rejecting
      // so we could use it to meaure the request duration
      const end = process.hrtime(start);
      const elapsedTime = end[0] + end[1] / 1e9;
      console.log(`request for ${clientName} took ${elapsedTime} seconds`);
    }
  },
});

Clients

// get all clients
platformClient.v1.clients.getClients()
  .then((resp) => {
    // log only the first
    console.log('getClients: resp', JSON.stringify(resp[0], null, '  '));
  }).catch((err) => {
    console.log('getClients: err', err);
  });

// get single client by apiKey
platformClient.v1.clients.getClients({ apiKey: 'some-apikey' })
  .then((resp) => {
    console.log('getClient: resp', JSON.stringify(resp, null, '  '));
  }).catch((err) => {
    console.log('getClient: err', err);
  });

// get clients with a query
platformClient.v1.clients.getClients({ query: '?info.status=integration||active' })
  .then((resp) => {
    console.log('getClient: resp', JSON.stringify(resp, null, '  '));
  }).catch((err) => {
    console.log('getClient: err', err);
  });

Products

// get product of a client by id
platformClient.v2.products.getProduct({
  apiKey: 'some-apikey', productId: '1771896',
})
  .then((resp) => {
    console.log('getProduct: resp', JSON.stringify(resp, null, '  '));
  }).catch((err) => {
    console.log('getProduct: err', err);
  });

// get product of a client by id and sales channel
platformClient.v2.products.getProduct({
  apiKey: 'some-apikey', productId: '1771896', salesChannel: '18',
})
  .then((resp) => {
    console.log('getProduct: resp', JSON.stringify(resp, null, '  '));
  }).catch((err) => {
    console.log('getProduct: err', err);
  });

Users

// get a list of anonymous ids from a real user id
platformClient.v2.users.getAnonymous({ apiKey: 'some-apikey', userId: 'some-id' })
  .then((resp) => {
      console.log('v2.users.getAnonymous: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.users.getAnonymous: err', err);
    });

// get a list of real user ids from an anonymous user id
platformClient.v2.users.getReals({ apiKey: 'some-apikey', anonymousId: 'some-id' })
  .then((resp) => {
      console.log('v2.users.getReals: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.users.getReals: err', err);
    });

Logs

// get a list of user transactions from a real user id
platformClient.v2.logs.getUserTransactions({ apiKey: 'some-apikey', userId: 'some-id' })
  .then((resp) => {
      console.log('v2.logs.getUserTransactions: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getUserTransactions: err', err);
    });

// get a list of user views from a real/anonymous user id
platformClient.v2.logs.getUserViews({ apiKey: 'some-apikey', userId: 'some-id' })
  .then((resp) => {
      console.log('v2.logs.getUserViews: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getUserViews: err', err);
    });

// get a list of cart views from a real/anonymous user id
platformClient.v2.logs.getCartViews({ apiKey: 'some-apikey', userId: 'some-id' })
  .then((resp) => {
      console.log('v2.logs.getCartViews: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getCartViews: err', err);
    });

LGPD Logs

If optout is set in params, the platform team validates that personalization is enabled for this touchpoint before returning any results.

// get a list of user transactions from a real user id
platformClient.v2.logs.getUserTransactions({ apiKey: 'some-apikey', userId: 'some-id', optout: '<touchpoint>' })
  .then((resp) => {
      console.log('v2.logs.getUserTransactions: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getUserTransactions: err', err);
    });

// get a list of user views from a real/anonymous user id
platformClient.v2.logs.getUserViews({ apiKey: 'some-apikey', userId: 'some-id', optout: '<touchpoint>' })
  .then((resp) => {
      console.log('v2.logs.getUserViews: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getUserViews: err', err);
    });

// get a list of cart views from a real/anonymous user id
platformClient.v2.logs.getCartViews({ apiKey: 'some-apikey', userId: 'some-id', optout: '<touchpoint>' })
  .then((resp) => {
      console.log('v2.logs.getCartViews: resp', JSON.stringify(resp, null, '  '));
    }).catch((err) => {
      console.log('v2.logs.getCartViews: err', err);
    });

touchpoint can be equals to general/onsite/email/search/banner/wishlist, etc. If it's equal to general, the personalization will be disabled for all products

Develop

Dependencies

Setup

To build the project:

Installs dependencies.

make build

Start the system

Runs the tests in watch mode.

make start

Stop the system

make stop

Remove the system

make remove

Update this README ToC

Needs markdown-toc.

markdown-toc -i README.md

Generate this documentation

Documentation will be in ./docs directory

make docs

Test

To run lint + unit tests

make test

lint

make lint

Unit tests

make mocha