Introduction
Welcome to the balena Node SDK documentation. These pages aim to describe all the functions supported by the SDK, as well as showing examples of their expected usage.
Installation
Install the balena SDK by running:
$ npm install --save balena-sdkBundling for browsers
If you're using webpack, browserify, or a similar tool then you probably want to bundle the balena SDK into your application yourself, rather than using the pre-built balena-browser.min.js bundle.
If you intend to do that, be sure to remove the following dependencies that are actually unnecessary in the browser, because they're only used in Node environments. This will significantly reduce the size of your resulting bundle:
fs
path
balena-settings-client
node-localstorage
fs/promises
mime
Bundling with pkg
The balena SDK includes builds for various ECMAScript versions that are dynamically selected at runtime (using @balena/es-version). For this reason, packagers like pkg are not able to automatically detect which assets to include in the output package. The following sample pkg section should be added to your application's package.json file to instruct pkg to bundle the required assets:
For more information, please refer to the respective documentation from the pkg project.
Trying balenaSDK in the browser
BalenaSDK is widely utilized in the balenaCloud dashboard to perform operations. The SDK has been made available in the browser console by default to test balenaSDK queries on the go. To use it, head to the balenaCloud dashboard and open the browser developer console. There, you will find balenaSDK initialized in the console and ready to run SDK queries.

If you feel something is missing, not clear or could be improved, please don't hesitate to open an issue in GitHub, we'll be happy to help.
Last updated
Was this helpful?