Improve this doc

Resin Node.js SDK

resin : object

Welcome to the Resin SDK documentation.

This document aims to describe all the functions supported by the SDK, as well as showing examples of their expected usage.

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.

Kind: global namespace

resin.interceptors : Array.<Interceptor>

The current array of interceptors to use. Interceptors intercept requests made internally and are executed in the order they appear in this array for requests, and in the reverse order for responses.

Kind: static property of resin
Summary: Array of interceptors
Access: public
Example

resin.interceptors.push({
    responseError: function (error) {
        console.log(error);
        throw error;
    })
});

interceptors.Interceptor : object

An interceptor implements some set of the four interception hook callbacks. To continue processing, each function should return a value or a promise that successfully resolves to a value.

To halt processing, each function should throw an error or return a promise that rejects with an error.

Kind: static typedef of interceptors
Properties

Name Type Description
request function Callback invoked before requests are made. Called with the request options, should return (or resolve to) new request options, or throw/reject.
response function Callback invoked before responses are returned. Called with the response, should return (or resolve to) a new response, or throw/reject.
requestError function Callback invoked if an error happens before a request. Called with the error itself, caused by a preceeding request interceptor rejecting/throwing an error for the request, or a failing in preflight token validation. Should return (or resolve to) new request options, or throw/reject.
responseError function Callback invoked if an error happens in the response. Called with the error itself, caused by a preceeding response interceptor rejecting/throwing an error for the request, a network error, or an error response from the server. Should return (or resolve to) a new response, or throw/reject.

resin.request : Object

The resin-request instance used internally. This should not be necessary in normal usage, but can be useful if you want to make an API request directly, using the same token and hooks as the SDK.

Kind: static property of resin
Summary: Resin request instance
Access: public
Example

resin.request.send({ url: 'http://api.resin.io/ping' });

resin.token : Object

The resin-token instance used internally. This should not be necessary in normal usage, but can be useful if you want to directly get or set the auth token that the SDK will use.

Kind: static property of resin
Summary: Resin token instance
Access: public
Example

resin.token.set('abcdef...');

resin.pine : Object

The resin-pine instance used internally. This should not be necessary in normal usage, but can be useful if you want to directly make pine queries to the api for some resource that isn't directly supported in the SDK.

Kind: static property of resin
Summary: Resin pine instance
Access: public
Example

resin.pine.get({
    resource: 'build/$count',
    options: {
        filter: { application: applicationId }
    }
});

resin.models : object

Kind: static namespace of resin

models.application : object

Kind: static namespace of models

application.getAll([options]) ⇒ Promise

Kind: static method of application
Summary: Get all applications
Access: public
Fulfil: Object[] - applications

Param Type Default Description
[options] Object {} extra pine options to use

Example

resin.models.application.getAll().then(function(applications) {
    console.log(applications);
});

Example

resin.models.application.getAll(function(error, applications) {
    if (error) throw error;
    console.log(applications);
});

application.get(nameOrId, [options]) ⇒ Promise

Kind: static method of application
Summary: Get a single application
Access: public
Fulfil: Object - application

Param Type Default Description
nameOrId String \ Number application name (string) or id (number)
[options] Object {} extra pine options to use

Example

resin.models.application.get('MyApp').then(function(application) {
    console.log(application);
});

Example

resin.models.application.get(123).then(function(application) {
    console.log(application);
});

Example

resin.models.application.get('MyApp', function(error, application) {
    if (error) throw error;
    console.log(application);
});

application.has(nameOrId) ⇒ Promise

Kind: static method of application
Summary: Check if an application exists
Access: public
Fulfil: Boolean - has application

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.application.has('MyApp').then(function(hasApp) {
    console.log(hasApp);
});

Example

resin.models.application.has(123).then(function(hasApp) {
    console.log(hasApp);
});

Example

resin.models.application.has('MyApp', function(error, hasApp) {
    if (error) throw error;
    console.log(hasApp);
});

application.hasAny() ⇒ Promise

Kind: static method of application
Summary: Check if the user has any applications
Access: public
Fulfil: Boolean - has any applications
Example

resin.models.application.hasAny().then(function(hasAny) {
    console.log('Has any?', hasAny);
});

Example

resin.models.application.hasAny(function(error, hasAny) {
    if (error) throw error;
    console.log('Has any?', hasAny);
});

application.getById(id) ⇒ Promise

Deprecated

Kind: static method of application
Summary: Get a single application by id
Access: public
Fulfil: Object - application

Param Type Description
id Number \ String application id

Example

resin.models.application.getById(89).then(function(application) {
    console.log(application);
});

Example

resin.models.application.getById(89, function(error, application) {
    if (error) throw error;
    console.log(application);
});

application.create(name, deviceType, [parentNameOrId]) ⇒ Promise

Kind: static method of application
Summary: Create an application
Access: public
Fulfil: Object - application

Param Type Description
name String application name
deviceType String device type slug
[parentNameOrId] Number \ String parent application name or id

Example

resin.models.application.create('My App', 'raspberry-pi').then(function(application) {
    console.log(application);
});

Example

resin.models.application.create('My App', 'raspberry-pi', 'ParentApp').then(function(application) {
    console.log(application);
});

Example

resin.models.application.create('My App', 'raspberry-pi', function(error, application) {
    if (error) throw error;
    console.log(application);
});

application.remove(nameOrId) ⇒ Promise

Kind: static method of application
Summary: Remove application
Access: public

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.application.remove('MyApp');

Example

resin.models.application.remove(123);

Example

resin.models.application.remove('MyApp', function(error) {
    if (error) throw error;
});

application.restart(nameOrId) ⇒ Promise

Kind: static method of application
Summary: Restart application
Access: public

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.application.restart('MyApp');

Example

resin.models.application.restart(123);

Example

resin.models.application.restart('MyApp', function(error) {
    if (error) throw error;
});

application.generateApiKey(nameOrId) ⇒ Promise

Kind: static method of application
Summary: Generate an API key for a specific application
Access: public
Fulfil: String - api key

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.application.generateApiKey('MyApp').then(function(apiKey) {
    console.log(apiKey);
});

Example

resin.models.application.generateApiKey(123).then(function(apiKey) {
    console.log(apiKey);
});

Example

resin.models.application.generateApiKey('MyApp', function(error, apiKey) {
    if (error) throw error;
    console.log(apiKey);
});

application.getApiKey(nameOrId) ⇒ Promise

Deprecated

Kind: static method of application
Summary: Get an API key for a specific application
Access: public
Fulfil: String - api key
See: generateApiKey

Param Type Description
nameOrId String \ Number application name (string) or id (number)

models.device : object

Kind: static namespace of models

device.getAll([options]) ⇒ Promise

Kind: static method of device
Summary: Get all devices
Access: public
Fulfil: Object[] - devices

Param Type Default Description
[options] Object {} extra pine options to use

Example

resin.models.device.getAll().then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getAll(function(error, devices) {
    if (error) throw error;
    console.log(devices);
});

device.getAllByApplication(nameOrId, [options]) ⇒ Promise

Kind: static method of device
Summary: Get all devices by application
Access: public
Fulfil: Object[] - devices

Param Type Default Description
nameOrId String \ Number application name (string) or id (number)
[options] Object {} extra pine options to use

Example

resin.models.device.getAllByApplication('MyApp').then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getAllByApplication(123).then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getAllByApplication('MyApp', function(error, devices) {
    if (error) throw error;
    console.log(devices);
});

device.getAllByParentDevice(parentUuidOrId, [options]) ⇒ Promise

Kind: static method of device
Summary: Get all devices by parent device
Access: public
Fulfil: Object[] - devices

Param Type Default Description
parentUuidOrId String \ Number parent device uuid (string) or id (number)
[options] Object {} extra pine options to use

Example

resin.models.device.getAllByParentDevice('7cf02a6').then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getAllByParentDevice(123).then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getAllByParentDevice('7cf02a6', function(error, devices) {
    if (error) throw error;
    console.log(devices);
});

device.get(uuidOrId, [options]) ⇒ Promise

Kind: static method of device
Summary: Get a single device
Access: public
Fulfil: Object - device

Param Type Default Description
uuidOrId String \ Number device uuid (string) or id (number)
[options] Object {} extra pine options to use

Example

resin.models.device.get('7cf02a6').then(function(device) {
    console.log(device);
})

Example

resin.models.device.get(123).then(function(device) {
    console.log(device);
})

Example

resin.models.device.get('7cf02a6', function(error, device) {
    if (error) throw error;
    console.log(device);
});

device.getByName(name) ⇒ Promise

Kind: static method of device
Summary: Get devices by name
Access: public
Fulfil: Object[] - devices

Param Type Description
name String device name

Example

resin.models.device.getByName('MyDevice').then(function(devices) {
    console.log(devices);
});

Example

resin.models.device.getByName('MyDevice', function(error, devices) {
    if (error) throw error;
    console.log(devices);
});

device.getName(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get the name of a device
Access: public
Fulfil: String - device name

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.getName('7cf02a6').then(function(deviceName) {
    console.log(deviceName);
});

Example

resin.models.device.getName(123).then(function(deviceName) {
    console.log(deviceName);
});

Example

resin.models.device.getName('7cf02a6', function(error, deviceName) {
    if (error) throw error;
    console.log(deviceName);
});

device.getApplicationName(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get application name
Access: public
Fulfil: String - application name

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.getApplicationName('7cf02a6').then(function(applicationName) {
    console.log(applicationName);
});

Example

resin.models.device.getApplicationName(123).then(function(applicationName) {
    console.log(applicationName);
});

Example

resin.models.device.getApplicationName('7cf02a6', function(error, applicationName) {
    if (error) throw error;
    console.log(applicationName);
});

device.getApplicationInfo(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get application container information
Access: public
Fulfil: Object - application info

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.getApplicationInfo('7cf02a6').then(function(appInfo) {
    console.log(appInfo);
});

Example

resin.models.device.getApplicationInfo(123).then(function(appInfo) {
    console.log(appInfo);
});

Example

resin.models.device.getApplicationInfo('7cf02a6', function(error, appInfo) {
    if (error) throw error;
    console.log(appInfo);
});

device.has(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Check if a device exists
Access: public
Fulfil: Boolean - has device

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.has('7cf02a6').then(function(hasDevice) {
    console.log(hasDevice);
});

Example

resin.models.device.has(123).then(function(hasDevice) {
    console.log(hasDevice);
});

Example

resin.models.device.has('7cf02a6', function(error, hasDevice) {
    if (error) throw error;
    console.log(hasDevice);
});

device.isOnline(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Check if a device is online
Access: public
Fulfil: Boolean - is device online

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.isOnline('7cf02a6').then(function(isOnline) {
    console.log('Is device online?', isOnline);
});

Example

resin.models.device.isOnline(123).then(function(isOnline) {
    console.log('Is device online?', isOnline);
});

Example

resin.models.device.isOnline('7cf02a6', function(error, isOnline) {
    if (error) throw error;
    console.log('Is device online?', isOnline);
});

device.getLocalIPAddresses(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get the local IP addresses of a device
Access: public
Fulfil: String[] - local ip addresses
Reject: Error Will reject if the device is offline

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.getLocalIPAddresses('7cf02a6').then(function(localIPAddresses) {
    localIPAddresses.forEach(function(localIP) {
        console.log(localIP);
    });
});

Example

resin.models.device.getLocalIPAddresses(123).then(function(localIPAddresses) {
    localIPAddresses.forEach(function(localIP) {
        console.log(localIP);
    });
});

Example

resin.models.device.getLocalIPAddresses('7cf02a6', function(error, localIPAddresses) {
    if (error) throw error;

    localIPAddresses.forEach(function(localIP) {
        console.log(localIP);
    });
});

device.remove(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Remove device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.remove('7cf02a6');

Example

resin.models.device.remove(123);

Example

resin.models.device.remove('7cf02a6', function(error) {
    if (error) throw error;
});

device.identify(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Identify device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.identify('7cf02a6');

Example

resin.models.device.identify(123);

Example

resin.models.device.identify('7cf02a6', function(error) {
    if (error) throw error;
});

device.rename(uuidOrId, newName) ⇒ Promise

Kind: static method of device
Summary: Rename device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
newName String the device new name

Example

resin.models.device.rename('7cf02a6', 'NewName');

Example

resin.models.device.rename(123, 'NewName');

Example

resin.models.device.rename('7cf02a6', 'NewName', function(error) {
    if (error) throw error;
});

device.note(uuidOrId, note) ⇒ Promise

Kind: static method of device
Summary: Note a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
note String the note

Example

resin.models.device.note('7cf02a6', 'My useful note');

Example

resin.models.device.note(123, 'My useful note');

Example

resin.models.device.note('7cf02a6', 'My useful note', function(error) {
    if (error) throw error;
});

device.setCustomLocation(uuidOrId, location) ⇒ Promise

Kind: static method of device
Summary: Set a custom location for a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
location Object the location ({ latitude: 123, longitude: 456 })

Example

resin.models.device.setCustomLocation('7cf02a6', { latitude: 123, longitude: 456 });

Example

resin.models.device.setCustomLocation(123, { latitude: 123, longitude: 456 });

Example

resin.models.device.setCustomLocation('7cf02a6', { latitude: 123, longitude: 456 }, function(error) {
    if (error) throw error;
});

device.unsetCustomLocation(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Clear the custom location of a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.unsetCustomLocation('7cf02a6');

Example

resin.models.device.unsetCustomLocation(123);

Example

resin.models.device.unsetLocation('7cf02a6', function(error) {
    if (error) throw error;
});

device.move(uuidOrId, applicationNameOrId) ⇒ Promise

Kind: static method of device
Summary: Move a device to another application
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
applicationNameOrId String \ Number application name (string) or id (number)

Example

resin.models.device.move('7cf02a6', 'MyApp');

Example

resin.models.device.move(123, 'MyApp');

Example

resin.models.device.move(123, 456);

Example

resin.models.device.move('7cf02a6', 'MyApp', function(error) {
    if (error) throw error;
});

device.startApplication(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Start application on device
Access: public
Fulfil: String - application container id

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.startApplication('7cf02a6').then(function(containerId) {
    console.log(containerId);
});

Example

resin.models.device.startApplication(123).then(function(containerId) {
    console.log(containerId);
});

Example

resin.models.device.startApplication('7cf02a6', function(error, containerId) {
    if (error) throw error;
    console.log(containerId);
});

device.stopApplication(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Stop application on device
Access: public
Fulfil: String - application container id

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.stopApplication('7cf02a6').then(function(containerId) {
    console.log(containerId);
});

Example

resin.models.device.stopApplication(123).then(function(containerId) {
    console.log(containerId);
});

Example

resin.models.device.stopApplication('7cf02a6', function(error, containerId) {
    if (error) throw error;
    console.log(containerId);
});

device.restartApplication(uuidOrId) ⇒ Promise

This function restarts the Docker container running the application on the device, but doesn't reboot the device itself.

Kind: static method of device
Summary: Restart application on device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.restartApplication('7cf02a6');

Example

resin.models.device.restartApplication(123);

Example

resin.models.device.restartApplication('7cf02a6', function(error) {
    if (error) throw error;
});

device.reboot(uuidOrId, [options]) ⇒ Promise

Kind: static method of device
Summary: Reboot device
Access: public

Param Type Default Description
uuidOrId String \ Number device uuid (string) or id (number)
[options] Object options
[options.force] Boolean false override update lock

Example

resin.models.device.reboot('7cf02a6');

Example

resin.models.device.reboot(123);

Example

resin.models.device.reboot('7cf02a6', function(error) {
    if (error) throw error;
});

device.shutdown(uuidOrId, [options]) ⇒ Promise

Kind: static method of device
Summary: Shutdown device
Access: public

Param Type Default Description
uuidOrId String \ Number device uuid (string) or id (number)
[options] Object options
[options.force] Boolean false override update lock

Example

resin.models.device.shutdown('7cf02a6');

Example

resin.models.device.shutdown(123);

Example

resin.models.device.shutdown('7cf02a6', function(error) {
    if (error) throw error;
});

device.purge(uuidOrId) ⇒ Promise

This function clears the user application's /data directory.

Kind: static method of device
Summary: Purge device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.purge('7cf02a6');

Example

resin.models.device.purge(123);

Example

resin.models.device.purge('7cf02a6', function(error) {
    if (error) throw error;
});

device.update(uuidOrId, options) ⇒ Promise

Kind: static method of device
Summary: Trigger an update check on the supervisor
Access: public

Param Type Default Description
uuidOrId String \ Number device uuid (string) or id (number)
options Object options
[options.force] Boolean false override update lock

Example

resin.models.device.update('7cf02a6', {
    force: true
});

Example

resin.models.device.update(123, {
    force: true
});

Example

resin.models.device.update('7cf02a6', {
    force: true
}, function(error) {
    if (error) throw error;
});

device.getDisplayName(deviceTypeSlug) ⇒ Promise

Kind: static method of device
Summary: Get display name for a device
Access: public
Fulfil: String - device display name
See: module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

Param Type Description
deviceTypeSlug String device type slug

Example

resin.models.device.getDisplayName('raspberry-pi').then(function(deviceTypeName) {
    console.log(deviceTypeName);
    // Raspberry Pi
});

Example

resin.models.device.getDisplayName('raspberry-pi', function(error, deviceTypeName) {
    if (error) throw error;
    console.log(deviceTypeName);
    // Raspberry Pi
});

device.getDeviceSlug(deviceTypeName) ⇒ Promise

Kind: static method of device
Summary: Get device slug
Access: public
Fulfil: String - device slug name
See: module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

Param Type Description
deviceTypeName String device type name

Example

resin.models.device.getDeviceSlug('Raspberry Pi').then(function(deviceTypeSlug) {
    console.log(deviceTypeSlug);
    // raspberry-pi
});

Example

resin.models.device.getDeviceSlug('Raspberry Pi', function(error, deviceTypeSlug) {
    if (error) throw error;
    console.log(deviceTypeSlug);
    // raspberry-pi
});

device.getSupportedDeviceTypes() ⇒ Promise

Kind: static method of device
Summary: Get supported device types
Access: public
Fulfil: String[] - supported device types
Example

resin.models.device.getSupportedDeviceTypes().then(function(supportedDeviceTypes) {
    supportedDeviceTypes.forEach(function(supportedDeviceType) {
        console.log('Resin supports:', supportedDeviceType);
    });
});

Example

resin.models.device.getSupportedDeviceTypes(function(error, supportedDeviceTypes) {
    if (error) throw error;

    supportedDeviceTypes.forEach(function(supportedDeviceType) {
        console.log('Resin supports:', supportedDeviceType);
    });
});

device.getManifestBySlug(slug) ⇒ Promise

Kind: static method of device
Summary: Get a device manifest by slug
Access: public
Fulfil: Object - device manifest

Param Type Description
slug String device slug

Example

resin.models.device.getManifestBySlug('raspberry-pi').then(function(manifest) {
    console.log(manifest);
});

Example

resin.models.device.getManifestBySlug('raspberry-pi', function(error, manifest) {
    if (error) throw error;
    console.log(manifest);
});

device.getManifestByApplication(nameOrId) ⇒ Promise

Kind: static method of device
Summary: Get a device manifest by application name
Access: public
Fulfil: Object - device manifest

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.device.getManifestByApplication('MyApp').then(function(manifest) {
    console.log(manifest);
});

Example

resin.models.device.getManifestByApplication(123).then(function(manifest) {
    console.log(manifest);
});

Example

resin.models.device.getManifestByApplication('MyApp', function(error, manifest) {
    if (error) throw error;
    console.log(manifest);
});

device.generateUniqueKey() ⇒ String

Kind: static method of device
Summary: Generate a random key, useful for both uuid and api key.
Returns: String - A generated key
Access: public
Example

randomKey = resin.models.device.generateUniqueKey();
// randomKey is a randomly generated key that can be used as either a uuid or an api key
console.log(randomKey);

device.register(applicationNameOrId, uuid) ⇒ Promise

Kind: static method of device
Summary: Register a new device with a Resin.io application.
Access: public
Fulfil: Object Device registration info ({ id: "...", uuid: "...", api_key: "..." })

Param Type Description
applicationNameOrId String \ Number application name (string) or id (number)
uuid String device uuid

Example

var uuid = resin.models.device.generateUniqueKey();
resin.models.device.register('MyApp', uuid).then(function(registrationInfo) {
    console.log(registrationInfo);
});

Example

var uuid = resin.models.device.generateUniqueKey();
resin.models.device.register(123, uuid).then(function(registrationInfo) {
    console.log(registrationInfo);
});

Example

var uuid = resin.models.device.generateUniqueKey();
resin.models.device.register('MyApp', uuid, function(error, registrationInfo) {
    if (error) throw error;
    console.log(registrationInfo);
});

device.hasDeviceUrl(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Check if a device is web accessible with device utls
Access: public
Fulfil: Boolean - has device url

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.hasDeviceUrl('7cf02a6').then(function(hasDeviceUrl) {
    if (hasDeviceUrl) {
        console.log('The device has device URL enabled');
    }
});

Example

resin.models.device.hasDeviceUrl(123).then(function(hasDeviceUrl) {
    if (hasDeviceUrl) {
        console.log('The device has device URL enabled');
    }
});

Example

resin.models.device.hasDeviceUrl('7cf02a6', function(error, hasDeviceUrl) {
    if (error) throw error;

    if (hasDeviceUrl) {
        console.log('The device has device URL enabled');
    }
});

device.getDeviceUrl(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get a device url
Access: public
Fulfil: String - device url

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.getDeviceUrl('7cf02a6').then(function(url) {
    console.log(url);
});

Example

resin.models.device.getDeviceUrl(123).then(function(url) {
    console.log(url);
});

Example

resin.models.device.getDeviceUrl('7cf02a6', function(error, url) {
    if (error) throw error;
    console.log(url);
});

device.enableDeviceUrl(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Enable device url for a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.enableDeviceUrl('7cf02a6');

Example

resin.models.device.enableDeviceUrl(123);

Example

resin.models.device.enableDeviceUrl('7cf02a6', function(error) {
    if (error) throw error;
});

device.disableDeviceUrl(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Disable device url for a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.disableDeviceUrl('7cf02a6');

Example

resin.models.device.disableDeviceUrl(123);

Example

resin.models.device.disableDeviceUrl('7cf02a6', function(error) {
    if (error) throw error;
});

device.enableTcpPing(uuidOrId) ⇒ Promise

When the device's connection to the Resin VPN is down, by default the device performs a TCP ping heartbeat to check for connectivity. This is enabled by default.

Kind: static method of device
Summary: Enable TCP ping for a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.enableTcpPing('7cf02a6');

Example

resin.models.device.enableTcpPing(123);

Example

resin.models.device.enableTcpPing('7cf02a6', function(error) {
    if (error) throw error;
});

device.disableTcpPing(uuidOrId) ⇒ Promise

When the device's connection to the Resin VPN is down, by default the device performs a TCP ping heartbeat to check for connectivity.

Kind: static method of device
Summary: Disable TCP ping for a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.disableTcpPing('7cf02a6');

Example

resin.models.device.disableTcpPing(123);

Example

resin.models.device.disableTcpPing('7cf02a6', function(error) {
    if (error) throw error;
});

device.ping(uuidOrId) ⇒ Promise

This is useful to signal that the supervisor is alive and responding.

Kind: static method of device
Summary: Ping a device
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.device.ping('7cf02a6');

Example

resin.models.device.ping(123);

Example

resin.models.device.ping('7cf02a6', function(error) {
    if (error) throw error;
});

device.getStatus(device) ⇒ Promise

Kind: static method of device
Summary: Get the status of a device
Access: public
Fulfil: String - device status

Param Type Description
device Object A device object

Example

resin.models.device.getStatus(device).then(function(status) {
    console.log(status);
});

Example

resin.models.device.getStatus(device, function(error, status) {
    if (error) throw error;
    console.log(status);
});

models.key : object

Kind: static namespace of models

key.getAll([options]) ⇒ Promise

Kind: static method of key
Summary: Get all ssh keys
Access: public
Fulfil: Object[] - ssh keys

Param Type Default Description
[options] Object {} extra pine options to use

Example

resin.models.key.getAll().then(function(keys) {
    console.log(keys);
});

Example

resin.models.key.getAll(function(error, keys) {
    if (error) throw error;
    console.log(keys);
});

key.get(id) ⇒ Promise

Kind: static method of key
Summary: Get a single ssh key
Access: public
Fulfil: Object - ssh key

Param Type Description
id String \ Number key id

Example

resin.models.key.get(51).then(function(key) {
    console.log(key);
});

Example

resin.models.key.get(51, function(error, key) {
    if (error) throw error;
    console.log(key);
});

key.remove(id) ⇒ Promise

Kind: static method of key
Summary: Remove ssh key
Access: public

Param Type Description
id String \ Number key id

Example

resin.models.key.remove(51);

Example

resin.models.key.remove(51, function(error) {
    if (error) throw error;
});

key.create(title, key) ⇒ Promise

Kind: static method of key
Summary: Create a ssh key
Access: public
Fulfil: Object - ssh key

Param Type Description
title String key title
key String the public ssh key

Example

resin.models.key.create('Main', 'ssh-rsa AAAAB....').then(function(key) {
    console.log(key);
});

Example

resin.models.key.create('Main', 'ssh-rsa AAAAB....', function(error, key) {
    if (error) throw error;
    console.log(key);
});

models.environment-variables : object

Kind: static namespace of models

environment-variables.device : object

Kind: static namespace of environment-variables

device.getAll(uuidOrId) ⇒ Promise

Kind: static method of device
Summary: Get all device environment variables
Access: public
Fulfil: Object[] - device environment variables

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.models.environmentVariables.device.getAll('7cf02a6').then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.device.getAll(123).then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.device.getAll('7cf02a6', function(error, environmentVariables) {
    if (error) throw error;
    console.log(environmentVariables)
});

device.getAllByApplication(nameOrId) ⇒ Promise

Kind: static method of device
Summary: Get all device environment variables for an application
Access: public
Fulfil: Object[] - device environment variables

Param Type Description
nameOrId String \ Number application name (string) or id (number)

Example

resin.models.environmentVariables.device.getAllByApplication('MyApp').then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.device.getAllByApplication(999999).then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.device.getAllByApplication('MyApp', function(error, environmentVariables) {
    if (error) throw error;
    console.log(environmentVariables)
});

device.create(uuidOrId, name, value) ⇒ Promise

Kind: static method of device
Summary: Create a device environment variable
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
name String environment variable name
value String environment variable value

Example

resin.models.environmentVariables.device.create('7cf02a6', 'EDITOR', 'vim');

Example

resin.models.environmentVariables.device.create(123, 'EDITOR', 'vim');

Example

resin.models.environmentVariables.device.create('7cf02a6', 'EDITOR', 'vim', function(error) {
    if (error) throw error;
});

device.update(id, value) ⇒ Promise

Kind: static method of device
Summary: Update a device environment variable
Access: public

Param Type Description
id String \ Number environment variable id
value String environment variable value

Example

resin.models.environmentVariables.device.update(2, 'emacs');

Example

resin.models.environmentVariables.device.update(2, 'emacs', function(error) {
    if (error) throw error;
});

device.remove(id) ⇒ Promise

Kind: static method of device
Summary: Remove a device environment variable
Access: public

Param Type Description
id String \ Number environment variable id

Example

resin.models.environmentVariables.device.remove(2);

Example

resin.models.environmentVariables.device.remove(2, function(error) {
    if (error) throw error;
});

environment-variables.getAllByApplication(applicationNameOrId) ⇒ Promise

Kind: static method of environment-variables
Summary: Get all environment variables by application
Access: public
Fulfil: Object[] - environment variables

Param Type Description
applicationNameOrId String \ Number application name (string) or id (number)

Example

resin.models.environmentVariables.getAllByApplication('MyApp').then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.getAllByApplication(123).then(function(environmentVariables) {
    console.log(environmentVariables);
});

Example

resin.models.environmentVariables.getAllByApplication('MyApp', function(error, environmentVariables) {
    if (error) throw error;
    console.log(environmentVariables);
});

environment-variables.create(applicationNameOrId, name, value) ⇒ Promise

Kind: static method of environment-variables
Summary: Create an environment variable for an application
Access: public

Param Type Description
applicationNameOrId String \ Number application name (string) or id (number)
name String environment variable name
value String environment variable value

Example

resin.models.environmentVariables.create('MyApp', 'EDITOR', 'vim');

Example

resin.models.environmentVariables.create(123, 'EDITOR', 'vim');

Example

resin.models.environmentVariables.create('MyApp', 'EDITOR', 'vim', function(error) {
    if (error) throw error;
});

environment-variables.update(id, value) ⇒ Promise

Kind: static method of environment-variables
Summary: Update an environment variable value from an application
Access: public

Param Type Description
id String \ Number environment variable id
value String environment variable value

Example

resin.models.environmentVariables.update(317, 'vim');

Example

resin.models.environmentVariables.update(317, 'vim', function(error) {
    if (error) throw error;
});

environment-variables.remove(id) ⇒ Promise

Kind: static method of environment-variables
Summary: Remove environment variable
Access: public

Param Type Description
id String \ Number environment variable id

Example

resin.models.environmentVariables.remove(51);

Example

resin.models.environmentVariables.remove(51, function(error) {
    if (error) throw error;
});

environment-variables.isSystemVariable(variable) ⇒ Boolean

Kind: static method of environment-variables
Summary: Check is a variable is system specific
Returns: Boolean - Whether a variable is system specific or not
Access: public

Param Type Description
variable Object environment variable

Example

resin.models.environmentVariables.isSystemVariable({
    name: 'RESIN_SUPERVISOR'
});
> true

Example

resin.models.environmentVariables.isSystemVariable({
    name: 'EDITOR'
});
> false

models.os : object

Kind: static namespace of models

os.getDownloadSize(deviceType, [version]) ⇒ Promise

Note! Currently only the raw (uncompressed) size is reported.

Kind: static method of os
Summary: Get OS download size estimate
Access: public
Fulfil: Number - OS image download size, in bytes.

Param Type Description
deviceType String device type slug
[version] String semver-compatible version or 'latest', defaults to 'latest'. The version must be the exact version number.

Example

resin.models.os.getDownloadSize('raspberry-pi').then(function(size) {
    console.log('The OS download size for raspberry-pi', size);
});

resin.models.os.getDownloadSize('raspberry-pi', function(error, size) {
    if (error) throw error;
    console.log('The OS download size for raspberry-pi', size);
});

os.getSupportedVersions(deviceType) ⇒ Promise

Kind: static method of os
Summary: Get OS supported versions
Access: public
Fulfil: Object - the versions information, of the following structure:

  • versions - an array of strings, containing exact version numbers supported by the current environment
  • recommended - the recommended version, i.e. the most recent version that is not pre-release, can be null
  • latest - the most recent version, including pre-releases
  • default - recommended (if available) or latest otherwise
Param Type Description
deviceType String device type slug

Example

resin.models.os.getSupportedVersions('raspberry-pi').then(function(osVersions) {
    console.log('Supported OS versions for raspberry-pi', osVersions);
});

resin.models.os.getSupportedVersions('raspberry-pi', function(error, osVersions) {
    if (error) throw error;
    console.log('Supported OS versions for raspberry-pi', osVersions);
});

os.getMaxSatisfyingVersion(deviceType, versionOrRange) ⇒ Promise

Kind: static method of os
Summary: Get the max OS version satisfying the given range
Access: public
Fulfil: String|null - the version number, or null if no matching versions are found

Param Type Description
deviceType String device type slug
versionOrRange String can be one of the exact version number, in which case it is returned if the version is supported, or null is returned otherwise, a semver-compatible range specification, in which case the most recent satisfying version is returned if it exists, or null is returned, 'latest' in which case the most recent version is returned, including pre-releases, 'recommended' in which case the recommended version is returned, i.e. the most recent version excluding pre-releases, which can be null if only pre-release versions are available, * 'default' in which case the recommended version is returned if available, or latest is returned otherwise. Defaults to 'latest'.

Example

resin.models.os.getSupportedVersions('raspberry-pi').then(function(osVersions) {
    console.log('Supported OS versions for raspberry-pi', osVersions);
});

resin.models.os.getSupportedVersions('raspberry-pi', function(error, osVersions) {
    if (error) throw error;
    console.log('Supported OS versions for raspberry-pi', osVersions);
});

os.getLastModified(deviceType, [version]) ⇒ Promise

Kind: static method of os
Summary: Get the OS image last modified date
Access: public
Fulfil: Date - last modified date

Param Type Description
deviceType String device type slug
[version] String semver-compatible version or 'latest', defaults to 'latest'. Unsupported (unpublished) version will result in rejection. The version must be the exact version number. To resolve the semver-compatible range use resin.model.os.getMaxSatisfyingVersion.

Example

resin.models.os.getLastModified('raspberry-pi').then(function(date) {
    console.log('The raspberry-pi image was last modified in ' + date);
});

resin.models.os.getLastModified('raspberrypi3', '2.0.0').then(function(date) {
    console.log('The raspberry-pi image was last modified in ' + date);
});

resin.models.os.getLastModified('raspberry-pi', function(error, date) {
    if (error) throw error;
    console.log('The raspberry-pi image was last modified in ' + date);
});

os.download(deviceType, [version]) ⇒ Promise

Kind: static method of os
Summary: Download an OS image
Access: public
Fulfil: ReadableStream - download stream

Param Type Description
deviceType String device type slug
[version] String semver-compatible version or 'latest', defaults to 'latest' Unsupported (unpublished) version will result in rejection. The version must be the exact version number. To resolve the semver-compatible range use resin.model.os.getMaxSatisfyingVersion.

Example

resin.models.os.download('raspberry-pi').then(function(stream) {
    stream.pipe(fs.createWriteStream('foo/bar/image.img'));
});

resin.models.os.download('raspberry-pi', function(error, stream) {
    if (error) throw error;
    stream.pipe(fs.createWriteStream('foo/bar/image.img'));
});

models.config : object

Kind: static namespace of models

config.getAll() ⇒ Promise

Kind: static method of config
Summary: Get all configuration
Access: public
Fulfil: Object - configuration
Example

resin.models.config.getAll().then(function(config) {
    console.log(config);
});

Example

resin.models.config.getAll(function(error, config) {
    if (error) throw error;
    console.log(config);
});

config.getDeviceTypes() ⇒ Promise

Kind: static method of config
Summary: Get device types
Access: public
Fulfil: Object[] - device types
Example

resin.models.config.getDeviceTypes().then(function(deviceTypes) {
    console.log(deviceTypes);
});

Example

resin.models.config.getDeviceTypes(function(error, deviceTypes) {
    if (error) throw error;
    console.log(deviceTypes);
})

config.getDeviceOptions(deviceType) ⇒ Promise

Kind: static method of config
Summary: Get configuration/initialization options for a device type
Access: public
Fulfil: Object[] - configuration options

Param Type Description
deviceType String device type slug

Example

resin.models.config.getDeviceOptions('raspberry-pi').then(function(options) {
    console.log(options);
});

Example

resin.models.config.getDeviceOptions('raspberry-pi', function(error, options) {
    if (error) throw error;
    console.log(options);
});

models.build : object

Kind: static namespace of models

build.get(id, [options]) ⇒ Promise

Kind: static method of build
Summary: Get a specific build
Access: public
Fulfil: Object - build

Param Type Default Description
id Number build id
[options] Object {} extra pine options to use

Example

resin.models.build.get(123).then(function(build) {
        console.log(build);
});

Example

resin.models.build.get(123, function(error, build) {
        if (error) throw error;
        console.log(build);
});

build.getAllByApplication(nameOrId, [options]) ⇒ Promise

Kind: static method of build
Summary: Get all builds from an application
Access: public
Fulfil: Object[] - builds

Param Type Default Description
nameOrId String \ Number application name (string) or id (number)
[options] Object {} extra pine options to use

Example

resin.models.build.getAllByApplication('MyApp').then(function(builds) {
        console.log(builds);
});

Example

resin.models.build.getAllByApplication(123).then(function(builds) {
        console.log(builds);
});

Example

resin.models.build.getAllByApplication('MyApp', function(error, builds) {
        if (error) throw error;
        console.log(builds);
});

resin.auth : object

Kind: static namespace of resin

auth.twoFactor : object

Kind: static namespace of auth

twoFactor.isEnabled() ⇒ Promise

Kind: static method of twoFactor
Summary: Check if two factor authentication is enabled
Access: public
Fulfil: Boolean - whether 2fa is enabled
Example

resin.auth.twoFactor.isEnabled().then(function(isEnabled) {
    if (isEnabled) {
        console.log('2FA is enabled for this account');
    }
});

Example

resin.auth.twoFactor.isEnabled(function(error, isEnabled) {
    if (error) throw error;

    if (isEnabled) {
        console.log('2FA is enabled for this account');
    }
});

twoFactor.isPassed() ⇒ Promise

Kind: static method of twoFactor
Summary: Check if two factor authentication challenge was passed
Access: public
Fulfil: Boolean - whether 2fa challenge was passed
Example

resin.auth.twoFactor.isPassed().then(function(isPassed) {
    if (isPassed) {
        console.log('2FA challenge passed');
    }
});

Example

resin.auth.twoFactor.isPassed(function(error, isPassed) {
    if (error) throw error;

    if (isPassed) {
        console.log('2FA challenge passed');
    }
});

twoFactor.challenge(code) ⇒ Promise

Kind: static method of twoFactor
Summary: Challenge two factor authentication
Access: public

Param Type Description
code String code

Example

resin.auth.twoFactor.challenge('1234');

Example

resin.auth.twoFactor.challenge('1234', function(error) {
    if (error) throw error;
});

auth.whoami() ⇒ Promise

This will only work if you used module:resin.auth.login to log in.

Kind: static method of auth
Summary: Return current logged in username
Access: public
Fulfil: (String|undefined) - username, if it exists
Example

resin.auth.whoami().then(function(username) {
    if (!username) {
        console.log('I\'m not logged in!');
    } else {
        console.log('My username is:', username);
    }
});

Example

resin.auth.whoami(function(error, username) {
    if (error) throw error;

    if (!username) {
        console.log('I\'m not logged in!');
    } else {
        console.log('My username is:', username);
    }
});

auth.authenticate(credentials) ⇒ Promise

You should use module:resin.auth.login when possible, as it takes care of saving the token and email as well.

Notice that if credentials contains extra keys, they'll be discarted by the server automatically.

Kind: static method of auth
Summary: Authenticate with the server
Access: protected
Fulfil: String - session token

Param Type Description
credentials Object in the form of email, password
credentials.email String the email
credentials.password String the password

Example

resin.auth.authenticate(credentials).then(function(token) {
    console.log('My token is:', token);
});

Example

resin.auth.authenticate(credentials, function(error, token) {
    if (error) throw error;
    console.log('My token is:', token);
});

auth.login(credentials) ⇒ Promise

If the login is successful, the token is persisted between sessions.

Kind: static method of auth
Summary: Login to Resin.io
Access: public

Param Type Description
credentials Object in the form of email, password
credentials.email String the email
credentials.password String the password

Example

resin.auth.login(credentials);

Example

resin.auth.login(credentials, function(error) {
    if (error) throw error;
});

auth.loginWithToken(token) ⇒ Promise

Login to resin with a session token instead of with credentials.

Kind: static method of auth
Summary: Login to Resin.io with a token
Access: public

Param Type Description
token String the auth token

Example

resin.auth.loginWithToken(token);

Example

resin.auth.loginWithToken(token, function(error) {
    if (error) throw error;
});

auth.isLoggedIn() ⇒ Promise

Kind: static method of auth
Summary: Check if you're logged in
Access: public
Fulfil: Boolean - is logged in
Example

resin.auth.isLoggedIn().then(function(isLoggedIn) {
    if (isLoggedIn) {
        console.log('I\'m in!');
    } else {
        console.log('Too bad!');
    }
});

Example

resin.auth.isLoggedIn(function(error, isLoggedIn) {
    if (error) throw error;

    if (isLoggedIn) {
        console.log('I\'m in!');
    } else {
        console.log('Too bad!');
    }
});

auth.getToken() ⇒ Promise

This will only work if you used module:resin.auth.login to log in.

Kind: static method of auth
Summary: Get current logged in user's token
Access: public
Fulfil: String - session token
Example

resin.auth.getToken().then(function(token) {
    console.log(token);
});

Example

resin.auth.getToken(function(error, token) {
    if (error) throw error;
    console.log(token);
});

auth.getUserId() ⇒ Promise

This will only work if you used module:resin.auth.login to log in.

Kind: static method of auth
Summary: Get current logged in user's id
Access: public
Fulfil: Number - user id
Example

resin.auth.getUserId().then(function(userId) {
    console.log(userId);
});

Example

resin.auth.getUserId(function(error, userId) {
    if (error) throw error;
    console.log(userId);
});

auth.getEmail() ⇒ Promise

This will only work if you used module:resin.auth.login to log in.

Kind: static method of auth
Summary: Get current logged in user's email
Access: public
Fulfil: String - user email
Example

resin.auth.getEmail().then(function(email) {
    console.log(email);
});

Example

resin.auth.getEmail(function(error, email) {
    if (error) throw error;
    console.log(email);
});

auth.logout() ⇒ Promise

Kind: static method of auth
Summary: Logout from Resin.io
Access: public
Example

resin.auth.logout();

Example

resin.auth.logout(function(error) {
    if (error) throw error;
});

auth.register([credentials]) ⇒ Promise

Kind: static method of auth
Summary: Register to Resin.io
Access: public
Fulfil: String - session token

Param Type Default Description
[credentials] Object {} in the form of username, password and email
credentials.email String the email
credentials.password String the password

Example

resin.auth.register({
    email: '[email protected]',
    password: 'secret'
}).then(function(token) {
    console.log(token);
});

Example

resin.auth.register({
    email: '[email protected]',
    password: 'secret'
}, function(error, token) {
    if (error) throw error;
    console.log(token);
});

resin.logs : object

Kind: static namespace of resin

logs.subscribe(uuidOrId) ⇒ Promise

The logs object yielded by this function emits the following events:

  • line: when a log line is received.
  • clear: when the logs are cleared.
  • error: when an error has happened.

Kind: static method of logs
Summary: Subscribe to device logs
Access: public
Fulfil: EventEmitter - logs
Todo

  • [ ] We should consider making this a readable stream.
Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.logs.subscribe('7cf02a6').then(function(logs) {
    logs.on('line', function(line) {
        console.log(line);
    });
    logs.on('clear', function() {
        console.clear();
    });
});

Example

resin.logs.subscribe(123).then(function(logs) {
    logs.on('line', function(line) {
        console.log(line);
    });
    logs.on('clear', function() {
        console.clear();
    });
});

Example

resin.logs.subscribe('7cf02a6', function(error, logs) {
    if (error) throw error;

    logs.on('line', function(line) {
        console.log(line);
    });
});

logs.history(uuidOrId, [options]) ⇒ Promise

Note: the default number of logs retrieved is 100. To get a different number pass the { count: N } to the options param. Also note that the actual number of log lines can be bigger as the Resin.io supervisor can combine lines sent in a short time interval

Kind: static method of logs
Summary: Get device logs history
Access: public
Fulfil: Object[] - history lines

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
[options] Object any options supported by https://www.pubnub.com/docs/nodejs-javascript/api-reference#history

Example

resin.logs.history('7cf02a6').then(function(lines) {
    lines.forEach(function(line) {
        console.log(line);
    });
});

Example

resin.logs.history(123).then(function(lines) {
    lines.forEach(function(line) {
        console.log(line);
    });
});

Example

resin.logs.history('7cf02a6', { count: 20 }, function(error, lines) {
    if (error) throw error;

    lines.forEach(function(line) {
        console.log(line);
    });
});

logs.historySinceLastClear(uuidOrId, [options]) ⇒ Promise

Note: the default number of logs retrieved is 200. To get a different number pass the { count: N } to the options param. Also note that the actual number of log lines can be bigger as the Resin.io supervisor can combine lines sent in a short time interval

Kind: static method of logs
Summary: Get device logs history after the most recent clear request
Access: public
Fulfil: Object[] - history lines

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)
[options] Object any options supported by https://www.pubnub.com/docs/nodejs-javascript/api-reference#history

Example

resin.logs.historySinceLastClear('7cf02a6', { count: 20 }).then(function(lines) {
    lines.forEach(function(line) {
        console.log(line);
    });
});

Example

resin.logs.historySinceLastClear(123).then(function(lines) {
    lines.forEach(function(line) {
        console.log(line);
    });
});

Example

resin.logs.historySinceLastClear('7cf02a6', function(error, lines) {
    if (error) throw error;

    lines.forEach(function(line) {
        console.log(line);
    });
});

logs.clear(uuidOrId) ⇒ Promise

Kind: static method of logs
Summary: Clear device logs history
Access: public

Param Type Description
uuidOrId String \ Number device uuid (string) or id (number)

Example

resin.logs.clear('7cf02a6').then(function() {
    console.log('OK');
});

Example

resin.logs.clear(123).then(function() {
    console.log('OK');
});

resin.settings : object

Kind: static namespace of resin

settings.get([key]) ⇒ Promise

Kind: static method of settings
Summary: Get a single setting. Only implemented in Node.js
Access: public
Fulfil: * - setting value

Param Type Description
[key] String setting key

Example

resin.settings.get('apiUrl').then(function(apiUrl) {
    console.log(apiUrl);
});

Example

resin.settings.get('apiUrl', function(error, apiUrl) {
    if (error) throw error;
    console.log(apiUrl);
});

settings.getAll() ⇒ Promise

Kind: static method of settings
Summary: Get all settings Only implemented in Node.js
Access: public
Fulfil: Object - settings
Example

resin.settings.getAll().then(function(settings) {
    console.log(settings);
});

Example

resin.settings.getAll(function(error, settings) {
    if (error) throw error;
    console.log(settings);
});