@signageos/sdk

Library which allows you to fully manage signageOS applets, devices, management & monitoring using JS.

Usage no npm install needed!

<script type="module">
  import signageosSdk from 'https://cdn.skypack.dev/@signageos/sdk';
</script>

README

SDK Library

Library which allows you to fully manage signageOS applets, devices, management & monitoring using JS.

Installation and prerequisities

npm install @signageos/sdk

Environment variables

Mandatory ENV variables:

  • SOS_AUTH_CLIENT_ID="...OAuthClientID..."
  • SOS_AUTH_SECRET="...OAuthSecret..."
  • SOS_API_IDENTIFICATION="...apiSecurityTokenID..."
  • SOS_API_SECURITY_TOKEN="...apiSecurityToken..."

Optional ENV variable adjustment (with default values):

  • SOS_API_URL="https://api.signageos.io"
  • SOS_REQUEST_MAX_ATTEMPTS="3"

You may visit the documentation [https://docs.signageos.io/api#rest-api-authentication] where you find out how to get the proper values.

Please see the .env.dist file where all mandatory ENV variables, required for SDK usage, are listed too.

REST API

Singleton

Just by setting ENV variables properly, you are ready to go and may use the api. If not ENV variables provided to node.js app, it tries to get values from user's ~/.sosrc which is configured by @signageos/cli dependency.

import {api} from "@signageos/sdk";

// retrieves the list of all devices
const devices = await api.device.list();

// retrieves the device info
const deviceInfo = await api.device.get('deviceUid');

// sets the device volume
await api.device.audio.set('deviceUid', {volume: 40});

// retrieves the list of all applets
const applets = await api.applet.list();

// ...

Instantiating

import {Api} from "@signageos/sdk";

const api = new Api(
    {
        url: 'https://api.signageos.io', // Optional
        organizationAuth: {
            clientId: '...OAuthClientID...',
            secret: '...OAuthSecret...',
        },
        accountAuth: {
            tokenId: '...apiSecurityTokenID...',
            token: '...apiSecurityToken...',
        },
        version: 'v1', // Optional
    },
);

// retrieves the list of all devices
const devices = await api.device.list();

// ...

Documentation

The complete SDK documentation may be generated by typedoc by running the command:

$ npm i && npm run docs

Once generated, the docs directory will contain the generated documentation.

The most useful documentation pages:

Development

Running the tests

This SDK library contains several unit and integration tests, You may locate inside the sdk root directory and run npm run test command.

If you properly configured all the mandatory environment variables either in .env file inside the sdk root or on your machine, and you set
the integration tests will be launched too. Otherwise only unit test would be run and integrations tests would be skipped.

Tip: you may use existing .env.dist file for creating the .env.