Particle API JS (Javascript SDK)

ParticleJS is JavaScript library for the Particle Device Cloud API for Node.js and the browser. It's open source so you can edit, change or even send in pull requests if you want to share!

This page contains examples to get started using the library.

For more details, see the detailed reference below and check the examples folder on GitHub.

Installation

Node.js

First, make sure you have node.js installed!

Next, open a command prompt or terminal, and install by typing:

$ npm install particle-api-js

Browser

Particle API JS can be included using bower:

$ bower install particle-api-js

Alternately, you can pull in Particle API JS from the JSDelivr and simply include the script in your HTML.

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/particle-api-js@10/dist/particle.min.js">
</script>

Now you will have a Particle object available that you can use in your application.

Responses

All functions in this library return promises.

particle.login({username: 'email@example.com', password: 'pass'}).then(
  function(data){
    console.log('API call completed on promise resolve: ', data.body.access_token);
  },
  function(err) {
    console.log('API call completed on promise fail: ', err);
  }
);

Examples

Here are some common use cases of using the functions in the Javascript library.

Logging in

login

You can create an account here. Use the token from login as the auth parameter in other calls.

var Particle = require('particle-api-js');
var particle = new Particle();
var token;

particle.login({username: 'user@email.com', password: 'pass'}).then(
  function(data) {
    token = data.body.access_token;
  },
  function (err) {
    console.log('Could not log in.', err);
  }
);

Device management

listDevices

List devices for a user with listDevices.

var token; // from result of particle.login
var devicesPr = particle.listDevices({ auth: token });

devicesPr.then(
  function(devices){
    console.log('Devices: ', devices);
  },
  function(err) {
    console.log('List devices call failed: ', err);
  }
);

callFunction

Call a function in device with callFunction.

var fnPr = particle.callFunction({ deviceId: 'DEVICE_ID', name: 'brew', argument: 'D0:HIGH', auth: token });

fnPr.then(
  function(data) {
    console.log('Function called succesfully:', data);
  }, function(err) {
    console.log('An error occurred:', err);
  });

The function needs to be defined in the firmware uploaded to the device and registered to the Particle cloud.

You pass along the name of the function and the params.

If the function call succeeds, data.return_value is the value returned by the function call on the Particle device.

claimDevice

Claims device and adds it to the user account with claimDevice

particle.claimDevice({ deviceId: 'DEVICE_ID', auth: token }).then(function(data) {
  console.log('device claim data:', data);
}, function(err) {
  console.log('device claim err:', err);
});

flashDevice

Flash firmware to device with flashDevice

particle.flashDevice({ deviceId: 'DEVICE_ID', files: { file1: './path/file1' }, auth: token }).then(function(data) {
  console.log('Device flashing started successfully:', data);
}, function(err) {
  console.log('An error occurred while flashing the device:', err);
});

getDevice

Gets all attributes for the device with getDevice

var devicesPr = particle.getDevice({ deviceId: 'DEVICE_ID', auth: token });

devicesPr.then(
  function(data){
    console.log('Device attrs retrieved successfully:', data);
  },
  function(err) {
    console.log('API call failed: ', err);
  }
);

getVariable

Gets a variable value for the device with getVariable

particle.getVariable({ deviceId: 'DEVICE_ID', name: 'temp', auth: token }).then(function(data) {
  console.log('Device variable retrieved successfully:', data);
}, function(err) {
  console.log('An error occurred while getting attrs:', err);
});

The variable needs to be defined in your device's code.

If getting the variable succeeds, data.body.result is the value of the variable on the Particle device.

removeDevice

Removes device from the user account with removeDevice

particle.removeDevice({ deviceId: 'DEVICE_ID', auth: token }).then(function(data) {
  console.log('remove call response:', data);
}, function(err) {
  console.log('An error occurred while removing:', err);
});

renameDevice

Renames device for the user account with renameDevice

particle.renameDevice({ deviceId: 'DEVICE_ID', name: 'new-name', auth: token }).then(function(data) {
  console.log('Device renamed successfully:', data);
}, function(err) {
  console.log('An error occurred while renaming device:', err);
});

signalDevice

Send a signal to the device to shout rainbows with signalDevice

particle.signalDevice({ deviceId: 'DEVICE_ID', signal: true, auth: token }).then(function(data) {
  console.log('Device is shouting rainbows:', data);
}, function(err) {
  console.log('Error sending a signal to the device:', err);
});

Send a signal to the device to stop shouting rainbows

particle.signalDevice({ deviceId: 'DEVICE_ID', signal: false, auth: token }).then(function(data) {
  console.log('The LED is back to normal:', data);
}, function(err) {
  console.log('Error sending a signal to the device:', err);
});

sendPublicKey

Send public key for a device to the cloud with sendPublicKey

particle.sendPublicKey({ deviceId: 'DEVICE_ID', key: 'key', auth: token }).then(function(data) {
  console.log('Public key sent successfully:', data);
}, function(err) {
  console.log('Error sending public key to the device:', err);
});

getEventStream

Get event listener to an stream in the Particle cloud with getEventStream

//Get events filtered by name
particle.getEventStream({ name: 'x', auth: token}).then(function(stream) {
  stream.on('event', function(data) {
    console.log("Event: ", data);
  });
});

//Get your devices events
particle.getEventStream({ deviceId: 'mine', auth: token }).then(function(stream) {
  stream.on('event', function(data) {
    console.log("Event: ", data);
  });
});

//Get test event for specific device
particle.getEventStream({ deviceId: 'DEVICE_ID', name: 'test', auth: token }).then(function(stream) {
  stream.on('event', function(data) {
    console.log("Event: ", data);
  });
});

data is an object with the following properties

{
  "name":"Uptime",
  "data":"5:28:54",
  "ttl":"60",
  "published_at":"2014-MM-DDTHH:mm:ss.000Z",
  "coreid":"012345678901234567890123"
}

When a network error occurs or the event stream has not received a heartbeat from the Particle API in 13 seconds, the event stream will disconnect and attempt to reconnect after 2 seconds. To customize the reconnection behavior, close the stream in the disconnect handler.

// This is not a functional reconnection implementation, only an illustration of the various events
let attempts = 10;
particle.getEventStream(options).then(function(stream) {
  stream.on('disconnect', function() {
    console.log('Disconnected from Particle event stream');
    attempts--;
    if (attempts <= 0) {
      console.log('Giving up reconnecting');
      stream.abort();
    }
  });
  stream.on('reconnect', function() {
    console.log('Attempting to reconnect to Particle event stream');
  });
  stream.on('reconnect-success', function() {
    console.log('Reconnected to Particle event stream');
    attempts = 10;
  });
  stream.on('reconnect-error', function(error) {
    console.log('Failed to reconnect to Particle event stream', error);
  });
});

In case your event handler throws an exception, the error event will be emitted.

particle.getEventStream(options).then(function(stream) {
  stream.on('event', function(data) {
    throw new Error('oops');
  });
  stream.on('error', function(error) {
    console.log('Error in handler', error);
  });
});

publishEvent

Register an event stream in the Particle cloud with publishEvent

var publishEventPr = particle.publishEvent({ name: 'test', data: JSON.stringify({ ok: true }), auth: token });

publishEventPr.then(
  function(data) {
    if (data.body.ok) { console.log("Event published succesfully") }
  },
  function(err) {
    console.log("Failed to publish event: " + err)
  }
);

Working with code

compileCode

Compiles files in the Particle cloud with compileCode

var ccPr = particle.compileCode({ files: { 'main.cpp': './project/main.cpp', 'my_lib/lib.cpp': './project/my_lib/lib.cpp' }, auth: token });

ccPr.then(
  function(data) {
    console.log('Code compilation started successfully:', data);
  }, function(err) {
    console.log('An error occurred while compiling the code:', err);
  });

Flashing

Flash firmware to a device with flashDevice

User management

createUser

Creates a user in the Particle cloud with createUser

particle.createUser({ username: 'example@email.com', password: 'pass' }).then(function(data) {

We try to login and get back an accessToken to verify user creation

  var loginPromise = particle.login('example@email.com', 'pass');

We'll use promises to check the result of the login process

    loginPromise.then(
      function(data) {
        console.log('Login successful! access_token:', data.access_token);
      },
      function(err) {
        console.log('Login failed:', err);
      }
    );
  }
});

listAccessTokens

Lists access tokens from the Particle cloud for the specified user with listAccessTokens

particle.listAccessTokens({ username: 'u@m.com', password: 'pass' }).then(function(data) {
  console.log('data on listing access tokens: ', data);
}, function(err) {
  console.log('error on listing access tokens: ', err);
});

deleteAccessToken

Removes an access token from the Particle cloud for the specified user with deleteAccessToken

particle.deleteAccessToken({ username: 'u@m.com', password: 'pass', token: 'token' }).then(function(data) {
  console.log('data on deleting accessToken: ', data);
}, function(err) {
  console.log('error on deleting accessToken: ', err);
});

Product support

If you are a product creator you can use the Javascript library to manage devices, firmware, integrations, and more.

Many of the functions in the Javascript library accept a product parameter. Pass your product ID number (such as 4567) or the slug (such as myproduct-v100) to make that function act on that product.

Detailed reference

Here a full reference of every function available in the Javascript client library.

constructor

Defined in: Particle.ts:86

Contructor for the Cloud API wrapper.

Create a new Particle object and call methods below on it.

Parameters

  • options? Options for this API call Options to be used for all requests (see Defaults)
    • baseUrl? string
    • clientId? string
    • clientSecret? string
    • tokenDuration? number
    • auth? string The access token. If not specified here, will have to be added to every request

Returns Particle

login

Defined in: Particle.ts:142

Login to Particle Cloud using an existing Particle acccount.

Parameters

  • options LoginOptions Options for this API call

Returns Promise<JSONResponse<LoginResponse>> A promise that resolves with the response data

sendOtp

Defined in: Particle.ts:168

If login failed with an 'mfa_required' error, this must be called with a valid OTP code to login

Parameters

  • options SendOtpOptions Options for this API call

Returns Promise<JSONResponse<LoginResponse>> A promise that resolves with the response data

enableMfa

Defined in: Particle.ts:192

Enable MFA on the currently logged in user

Parameters

  • options EnableMfaOptions Options for this API call

Returns Promise<JSONResponse<EnableMfaResponse>> A promise that resolves with the response data

confirmMfa

Defined in: Particle.ts:207

Confirm MFA for the user. This must be called with current TOTP code, determined from the results of enableMfa(). You will be prompted to enter an OTP code every time you login after enrollment is confirmed.

Parameters

  • options ConfirmMfaOptions Options for this API call

Returns Promise<JSONResponse<ConfirmMfaResponse>> A promise that resolves with the response data

disableMfa

Defined in: Particle.ts:232

Disable MFA for the user.

Parameters

  • options DisableMfaOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

createCustomer

Defined in: Particle.ts:252

Create Customer for Product.

Parameters

  • options CreateCustomerOptions Options for this API call

Returns Promise<JSONResponse<CreateCustomerResponse>> A promise that resolves with the response data

loginAsClientOwner

Defined in: Particle.ts:275

Login to Particle Cloud using an OAuth client.

Parameters

  • options? LoginAsClientOwnerOptions = {} Options for this API call

Returns Promise<JSONResponse<LoginResponse>> A promise that resolves with the response data

createUser

Defined in: Particle.ts:300

Create a user account for the Particle Cloud

Parameters

  • options Options for this API call
    • username string Email of the new user
    • password string Password
    • accountInfo? Record<string, string | number | boolean> Object that contains account information fields such as user real name, company name, business account flag etc
    • utm? Record<string, string> Object that contains info about the campaign that lead to this user creation
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

resetPassword

Defined in: Particle.ts:322

Send reset password email for a Particle Cloud user account

Parameters

  • options ResetPasswordOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

deleteAccessToken

Defined in: Particle.ts:339

Revoke an access token

Parameters

  • options DeleteAccessTokenOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

deleteCurrentAccessToken

Defined in: Particle.ts:355

Revoke the current session access token

Parameters

  • options DeleteCurrentAccessTokenOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

deleteActiveAccessTokens

Defined in: Particle.ts:372

Revoke all active access tokens

Parameters

  • options DeleteActiveAccessTokensOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

deleteUser

Defined in: Particle.ts:390

Delete the current user

Parameters

  • options DeleteUserOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

trackingIdentity

Defined in: Particle.ts:410

Retrieves the information that is used to identify the current login for tracking.

Parameters

  • options? TrackingIdentityOptions = {} Options for this API call

Returns Promise<JSONResponse<TrackingIdentityResponse>> A promise that resolves with the response data

listDevices

Defined in: Particle.ts:436

List devices claimed to the account or product

Parameters

  • options Options for this API call
    • deviceId? string (Product only) Filter results to devices with this ID (partial matching)
    • deviceName? string (Product only) Filter results to devices with this name (partial matching)
    • groups? string[] (Product only) A list of full group names to filter results to devices belonging to these groups only.
    • sortAttr? string (Product only) The attribute by which to sort results. See API docs for options.
    • sortDir? string (Product only) The direction of sorting. See API docs for options.
    • page? number (Product only) Current page of results
    • perPage? number (Product only) Records per page
    • product? string | number List devices in this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<DeviceInfo[]>> A promise that resolves with the response data

getDevice

Defined in: Particle.ts:468

Get detailed informationa about a device

Parameters

  • options GetDeviceOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

claimDevice

Defined in: Particle.ts:483

Claim a device to the account. The device must be online and unclaimed.

Parameters

  • options ClaimDeviceOptions Options for this API call

Returns Promise<JSONResponse<ClaimResponse>> A promise that resolves with the response data

addDeviceToProduct

Defined in: Particle.ts:508

Add a device to a product or move device out of quarantine.

Parameters

  • options AddDeviceToProductOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

removeDevice

Defined in: Particle.ts:540

Unclaim / Remove a device from your account or product, or deny quarantine

Parameters

  • options RemoveDeviceOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

removeDeviceOwner

Defined in: Particle.ts:556

Unclaim a product device its the owner, but keep it in the product

Parameters

  • options RemoveDeviceOwnerOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

renameDevice

Defined in: Particle.ts:572

Rename a device

Parameters

  • options RenameDeviceOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

signalDevice

Defined in: Particle.ts:587

Instruct the device to turn on/off the LED in a rainbow pattern

Parameters

  • options SignalDeviceOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

setDeviceNotes

Defined in: Particle.ts:602

Store some notes about device

Parameters

  • options Options for this API call
    • deviceId string Device ID or Name
    • notes string Your notes about this device
    • product? string | number Device in this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

markAsDevelopmentDevice

Defined in: Particle.ts:617

Mark device as being used in development of a product so it opts out of automatic firmware updates

Parameters

  • options Options for this API call
    • deviceId string Device ID or Name
    • development? boolean = true Set to true to mark as development, false to return to product fleet
    • product string | number Device in this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

lockDeviceProductFirmware

Defined in: Particle.ts:633

Mark device as being used in development of a product, so it opts out of automatic firmware updates

Parameters

  • options Options for this API call
    • deviceId string Device ID or Name
    • desiredFirmwareVersion number Lock the product device to run this firmware version.
    • flash? boolean Immediately flash firmware indicated by desiredFirmwareVersion
    • product string | number Device in this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

unlockDeviceProductFirmware

Defined in: Particle.ts:647

Mark device as receiving automatic firmware updates

Parameters

  • options Options for this API call
    • deviceId string Device ID or Name
    • product string | number Device in this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

updateDevice

Defined in: Particle.ts:668

Update multiple device attributes at the same time

Parameters

  • options UpdateDeviceOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

unprotectDevice

Defined in: Particle.ts:700

Disable device protection.

Parameters

  • options UnprotectDeviceOptions Options for this API call.

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

provisionDevice

Defined in: Particle.ts:727

Provision a new device for products that allow self-provisioning

Parameters

  • options ProvisionDeviceOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo>> A promise that resolves with the response data

getClaimCode

Defined in: Particle.ts:749

Generate a claim code to use in the device claiming process. To generate a claim code for a product, the access token MUST belong to a customer of the product.

Parameters

  • options GetClaimCodeOptions Options for this API call

Returns Promise<JSONResponse<ClaimCodeResponse>> A promise that resolves with the response data

getVariable

Defined in: Particle.ts:765

Get the value of a device variable

Parameters

  • options GetVariableOptions Options for this API call

Returns Promise<JSONResponse<DeviceVariableResponse>> A promise that resolves with the response data

flashDevice

Defined in: Particle.ts:785

Compile and flash application firmware to a device. Pass a pre-compiled binary to flash it directly to the device.

Parameters

  • options FlashDeviceOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

compileCode

Defined in: Particle.ts:809

Compile firmware using the Particle Cloud

Parameters

  • options CompileCodeOptions Options for this API call

Returns Promise<JSONResponse<CompileResponse>> A promise that resolves with the response data

downloadFirmwareBinary

Defined in: Particle.ts:838

Download a firmware binary

Parameters

  • options DownloadFirmwareBinaryOptions Options for this API call

Returns Promise<Buffer | ArrayBuffer> A promise that resolves with the binary data

sendPublicKey

Defined in: Particle.ts:860

Send a new device public key to the Particle Cloud

Parameters

  • options Options for this API call
    • deviceId string Device ID or Name
    • key string | Buffer Public key contents
    • algorithm? string Algorithm used to generate the public key. Valid values are rsa or ecc.
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

callFunction

Defined in: Particle.ts:888

Call a device function

Parameters

  • options CallFunctionOptions Options for this API call

Returns Promise<JSONResponse<FunctionCallResponse>> A promise that resolves with the response data

getEventStream

Defined in: Particle.ts:906

Get a stream of events

Parameters

  • options GetEventStreamOptions Options for this API call

Returns Promise<EventStream> A promise that resolves with the response data emit 'event' events.

publishEvent

Defined in: Particle.ts:945

Publish a event to the Particle Cloud

Parameters

  • options Options for this API call
    • name string Event name
    • data? string Event data
    • isPrivate? boolean Should the event be publicly available?
    • product? string | number Event for this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

Hook

Defined in: Particle.ts:940

Type: Object

Properties

  • method string (optional, default POST) Type of web request triggered by the Webhook (GET, POST, PUT, or DELETE)
  • auth object (optional) Auth data like { user: 'me', pass: '1234' } for basic auth or { bearer: 'token' } to send with the Webhook request
  • headers object (optional) Additional headers to add to the Webhook like { 'X-ONE': '1', X-TWO: '2' }
  • query object (optional) Query params to add to the Webhook request like { foo: 'foo', bar: 'bar' }
  • json object (optional) JSON data to send with the Webhook request - sets Content-Type to application/json
  • form object (optional) Form data to send with the Webhook request - sets Content-Type to application/x-www-form-urlencoded
  • body string (optional) Custom body to send with the Webhook request
  • responseTemplate object (optional) Template to use to customize the Webhook response body
  • responseEvent object (optional) The Webhook response event name that your devices can subscribe to
  • errorResponseEvent object (optional) The Webhook error response event name that your devices can subscribe to

createWebhook

Defined in: Particle.ts:980

Create a webhook

Parameters

  • options Options for this API call
    • event string The name of the Particle event that should trigger the Webhook
    • url string The web address that will be targeted when the Webhook is triggered
    • device? string Trigger Webhook only for this device ID or Name
    • rejectUnauthorized? boolean Set to false to skip SSL certificate validation of the target URL
    • noDefaults? boolean Don't include default event data in the webhook request
    • hook? { method?: string; auth?: Record<string, string>; headers?: Record<string, string>; query?: Record<string, string>; json?: object; form?: object; body?: string; responseTemplate?: string; responseEvent?: string; errorResponseEvent?: string; } Webhook configuration settings
      • hook.method? string
      • hook.auth? Record<string, string>
      • hook.headers? Record<string, string>
      • hook.query? Record<string, string>
      • hook.json? object
      • hook.form? object
      • hook.body? string
      • hook.responseTemplate? string
      • hook.responseEvent? string
      • hook.errorResponseEvent? string
    • product? string | number Webhook for this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<CreateWebhookResponse>> A promise that resolves with the response data

deleteWebhook

Defined in: Particle.ts:1014

Delete a webhook

Parameters

  • options DeleteWebhookOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listWebhooks

Defined in: Particle.ts:1028

List all webhooks owned by the account or product

Parameters

  • options ListWebhooksOptions Options for this API call

Returns Promise<JSONResponse<WebhookInfo[]>> A promise that resolves with the response data

createIntegration

Defined in: Particle.ts:1048

Create an integration to send events to an external service

See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-

Parameters

  • options CreateIntegrationOptions Options for this API call

Returns Promise<JSONResponse<IntegrationInfo>> A promise that resolves with the response data

editIntegration

Defined in: Particle.ts:1070

Edit an integration to send events to an external service

See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-

Parameters

  • options EditIntegrationOptions Options for this API call

Returns Promise<JSONResponse<IntegrationInfo>> A promise that resolves with the response data

deleteIntegration

Defined in: Particle.ts:1087

Delete an integration to send events to an external service

Parameters

  • options DeleteIntegrationOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listIntegrations

Defined in: Particle.ts:1101

List all integrations owned by the account or product

Parameters

  • options ListIntegrationsOptions Options for this API call

Returns Promise<JSONResponse<IntegrationInfo[]>> A promise that resolves with the response data

getUserInfo

Defined in: Particle.ts:1114

Get details about the current user

Parameters

  • options Options for this API call
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<UserInfo>> A promise that resolves with the response data

setUserInfo

Defined in: Particle.ts:1127

Set details on the current user

Parameters

  • options Options for this API call
    • accountInfo? Record<string, string | number | boolean> Set user's extended info fields (name, business account, company name, etc)
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<UserInfo>> A promise that resolves with the response data

changeUsername

Defined in: Particle.ts:1143

Change username (i.e, email)

Parameters

  • options ChangeUsernameOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

changeUserPassword

Defined in: Particle.ts:1164

Change user's password

Parameters

  • options ChangeUserPasswordOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listSIMs

Defined in: Particle.ts:1188

List SIM cards owned by a user or product

Parameters

  • options ListSIMsOptions Options for this API call

Returns Promise<JSONResponse<SimInfo[]>> A promise that resolves with the response data

getSIMDataUsage

Defined in: Particle.ts:1204

Get data usage for one SIM card for the current billing period

Parameters

  • options GetSIMDataUsageOptions Options for this API call

Returns Promise<JSONResponse<SimDataUsage>> A promise that resolves with the response data

getFleetDataUsage

Defined in: Particle.ts:1221

Get data usage for all SIM cards in a product the current billing period

Parameters

  • options GetFleetDataUsageOptions Options for this API call

Returns Promise<JSONResponse<SimDataUsage>> A promise that resolves with the response data

checkSIM

Defined in: Particle.ts:1239

Check SIM status

Parameters

  • options CheckSIMOptions Options for this API call

Returns Promise<JSONResponse<SimInfo>> A promise that resolves with the response data

activateSIM

Defined in: Particle.ts:1256

Activate and add SIM cards to an account or product

Parameters

  • options ActivateSIMOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

deactivateSIM

Defined in: Particle.ts:1277

Deactivate a SIM card so it doesn't incur data usage in future months.

Parameters

  • options DeactivateSIMOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

reactivateSIM

Defined in: Particle.ts:1294

Reactivate a SIM card the was deactivated or unpause a SIM card that was automatically paused

Parameters

  • options ReactivateSIMOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

updateSIM

Defined in: Particle.ts:1311

Update SIM card data limit

Parameters

  • options UpdateSIMOptions Options for this API call

Returns Promise<JSONResponse<SimInfo>> A promise that resolves with the response data

removeSIM

Defined in: Particle.ts:1327

Remove a SIM card from an account so it can be activated by a different account

Parameters

  • options RemoveSIMOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listBuildTargets

Defined in: Particle.ts:1341

List valid build targets to be used for compiling

Parameters

  • options ListBuildTargetsOptions Options for this API call

Returns Promise<JSONResponse<BuildTargetsResponse>> A promise that resolves with the response data

listLibraries

Defined in: Particle.ts:1370

List firmware libraries

Parameters

  • options ListLibrariesOptions Options for this API call

Returns Promise<JSONResponse<{ data: LibraryInfo[]; }>> A promise

getLibrary

Defined in: Particle.ts:1403

Get firmware library details

Parameters

  • options GetLibraryOptions Options for this API call

Returns Promise<JSONResponse<{ data: LibraryInfo; }>> A promise

getLibraryVersions

Defined in: Particle.ts:1424

Firmware library details for each version

Parameters

  • options GetLibraryVersionsOptions Options for this API call

Returns Promise<JSONResponse<{ data: LibraryInfo[]; }>> A promise

contributeLibrary

Defined in: Particle.ts:1444

Contribute a new library version from a compressed archive

Parameters

  • options ContributeLibraryOptions Options for this API call

Returns Promise<JSONResponse<{ data: LibraryInfo; }>> A promise

publishLibrary

Defined in: Particle.ts:1468

Publish the latest version of a library to the public

Parameters

  • options PublishLibraryOptions Options for this API call

Returns Promise<JSONResponse<{ data: LibraryInfo; }>> A promise

deleteLibrary

Defined in: Particle.ts:1489

Delete one version of a library or an entire private library

Parameters

  • options DeleteLibraryOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

downloadFile

Defined in: Particle.ts:1507

Download an external file that may not be on the API

Parameters

  • options DownloadFileOptions Options for this API call

Returns Promise<Buffer | ArrayBuffer> A promise that resolves with the binary data

listOAuthClients

Defined in: Particle.ts:1520

List OAuth client created by the account

Parameters

  • options ListOAuthClientsOptions Options for this API call

Returns Promise<JSONResponse<{ clients: OAuthClientInfo[]; }>> A promise

createOAuthClient

Defined in: Particle.ts:1538

Create an OAuth client

Parameters

  • options Options for this API call
    • name string Name of the OAuth client
    • type string web, installed or web
    • redirect_uri? string URL to redirect after OAuth flow. Only for type web.
    • scope? Record<string, string> Limits what the access tokens created by this client can do.
    • product? string | number Create client for this product ID or slug
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<OAuthClientInfo>> A promise that resolves with the response data

updateOAuthClient

Defined in: Particle.ts:1556

Update an OAuth client

Parameters

  • options UpdateOAuthClientOptions Options for this API call

Returns Promise<JSONResponse<OAuthClientInfo>> A promise that resolves with the response data

deleteOAuthClient

Defined in: Particle.ts:1572

Delete an OAuth client

Parameters

  • options DeleteOAuthClientOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listProducts

Defined in: Particle.ts:1585

List products the account has access to

Parameters

  • options ListProductsOptions Options for this API call

Returns Promise<JSONResponse<{ products: ProductInfo[]; }>> A promise

getProduct

Defined in: Particle.ts:1598

Get detailed information about a product

Parameters

  • options GetProductOptions Options for this API call

Returns Promise<JSONResponse<{ product: ProductInfo; }>> A promise

listProductFirmware

Defined in: Particle.ts:1611

List product firmware versions

Parameters

  • options ListProductFirmwareOptions Options for this API call

Returns Promise<JSONResponse<ProductFirmwareInfo[]>> A promise that resolves with the response data

uploadProductFirmware

Defined in: Particle.ts:1629

List product firmware versions

Parameters

  • options UploadProductFirmwareOptions Options for this API call

Returns Promise<JSONResponse<ProductFirmwareInfo>> A promise that resolves with the response data

getProductFirmware

Defined in: Particle.ts:1657

Get information about a product firmware version

Parameters

  • options GetProductFirmwareOptions Options for this API call

Returns Promise<JSONResponse<ProductFirmwareInfo>> A promise that resolves with the response data

updateProductFirmware

Defined in: Particle.ts:1678

Update information for a product firmware version

Parameters

  • options UpdateProductFirmwareOptions Options for this API call

Returns Promise<JSONResponse<ProductFirmwareInfo>> A promise that resolves with the response data

downloadProductFirmware

Defined in: Particle.ts:1693

Download a product firmware binary

Parameters

  • options DownloadProductFirmwareOptions Options for this API call

Returns Promise<Buffer | ArrayBuffer> A promise that resolves with the binary data

downloadManufacturingBackup

Defined in: Particle.ts:1713

Download a tachyon manufacturing backup files

Parameters

  • options DownloadManufacturingBackupOptions Options for this API call

Returns Promise<Buffer | ArrayBuffer> A promise that resolves with the binary data

releaseProductFirmware

Defined in: Particle.ts:1734

Release a product firmware version as the default version

Parameters

  • options ReleaseFirmwareOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listTeamMembers

Defined in: Particle.ts:1748

List product team members

Parameters

  • options ListTeamMembersOptions Options for this API call

Returns Promise<JSONResponse<TeamMember[]>> A promise that resolves with the response data

inviteTeamMember

Defined in: Particle.ts:1767

Invite Particle user to a product team

Parameters

  • options InviteTeamMemberOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

removeTeamMember

Defined in: Particle.ts:1787

Remove Particle user to a product team

Parameters

  • options RemoveTeamMemberOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

lookupSerialNumber

Defined in: Particle.ts:1805

Fetch details about a serial number

Parameters

  • options LookupSerialNumberOptions Options for this API call

Returns Promise<JSONResponse<SerialNumberResponse>> A promise that resolves with the response data

createMeshNetwork

Defined in: Particle.ts:1825

Create a mesh network

Parameters

  • options CreateMeshNetworkOptions Options for this API call

Returns Promise<JSONResponse<NetworkInfo>> A promise that resolves with the response data

removeMeshNetwork

Defined in: Particle.ts:1844

Remove a mesh network.

Parameters

  • options RemoveMeshNetworkOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listMeshNetworks

Defined in: Particle.ts:1858

List all mesh networks

Parameters

  • options ListMeshNetworksOptions Options for this API call

Returns Promise<JSONResponse<NetworkInfo[]>> A promise that resolves with the response data

getMeshNetwork

Defined in: Particle.ts:1872

Get information about a mesh network.

Parameters

  • options GetMeshNetworkOptions Options for this API call

Returns Promise<JSONResponse<NetworkInfo>> A promise that resolves with the response data

updateMeshNetwork

Defined in: Particle.ts:1887

Modify a mesh network.

Parameters

  • options UpdateMeshNetworkOptions Options for this API call

Returns Promise<JSONResponse<NetworkInfo>> A promise that resolves with the response data

addMeshNetworkDevice

Defined in: Particle.ts:1907

Add a device to a mesh network.

Parameters

  • options Options for this API call
    • networkId string Network ID or name
    • deviceId string Device ID
    • auth? string The access token. Can be ignored if provided in constructor
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<NetworkInfo>> A promise that resolves with the response data

removeMeshNetworkDevice

Defined in: Particle.ts:1928

Remove a device from a mesh network.

Parameters

  • options RemoveMeshNetworkDeviceOptions Options for this API call

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listMeshNetworkDevices

Defined in: Particle.ts:1959

List all devices of a mesh network.

Parameters

  • options ListMeshNetworkDevicesOptions Options for this API call

Returns Promise<JSONResponse<DeviceInfo[]>> A promise that resolves with the response data

getProductConfiguration

Defined in: Particle.ts:1979

Get product configuration

Parameters

  • options GetProductConfigurationOptions Options for this API call

Returns Promise<JSONResponse<ProductConfigurationResponse>> A promise that resolves with the response data

getProductConfigurationSchema

Defined in: Particle.ts:1997

Get product configuration schema

Parameters

  • options GetProductConfigurationSchemaOptions Options for this API call

Returns Promise<JSONResponse<object>> A promise that resolves with the response data

getProductDeviceConfiguration

Defined in: Particle.ts:2017

Get product device's configuration

Parameters

  • options GetProductDeviceConfigurationOptions Options for this API call

Returns Promise<JSONResponse<ProductConfigurationResponse>> A promise that resolves with the response data

getProductDeviceConfigurationSchema

Defined in: Particle.ts:2036

Get product device's configuration schema

Parameters

  • options GetProductDeviceConfigurationSchemaOptions Options for this API call

Returns Promise<JSONResponse<object>> A promise that resolves with the response data

setProductConfiguration

Defined in: Particle.ts:2056

Set product configuration

Parameters

  • options SetProductConfigurationOptions Options for this API call

Returns Promise<JSONResponse<ProductConfigurationResponse>> A promise that resolves with the response data

setProductDeviceConfiguration

Defined in: Particle.ts:2077

Set product configuration for a specific device within the product

Parameters

  • options SetProductDeviceConfigurationOptions Options for this API call

Returns Promise<JSONResponse<ProductConfigurationResponse>> A promise that resolves with the response data

getProductLocations

Defined in: Particle.ts:2104

Query location for devices within a product

Parameters

  • options GetProductLocationsOptions Options for this API call

Returns Promise<JSONResponse<LocationListResponse>> A promise that resolves with the response data

getProductDeviceLocations

Defined in: Particle.ts:2138

Query location for one device within a product

Parameters

  • options GetProductDeviceLocationsOptions Options for this API call

Returns Promise<JSONResponse<DeviceLocationInfo>> A promise that resolves with the response data

executeLogic

Defined in: Particle.ts:2166

Executes the provided logic function once and returns the result. No logs, runs, etc are saved

NOTE: Any external interactions such as Particle.publish will actually occur when the logic is executed.

Parameters

  • options ExecuteLogicOptions The options for creating the logic function.

Returns Promise<JSONResponse<ExecuteLogicResponse>> A promise that resolves with the response data

createLogicFunction

Defined in: Particle.ts:2194

Creates a new logic function in the specified organization or sandbox using the provided function data.

When you create a logic function with Event logic triggers, events will immediately start being handled by the function code.

When you create a Scheduled logic trigger, it will immediately be scheduled at the next time according to the cron and start_at properties.

Parameters

  • options The options for creating the logic function.
    • auth? string The access token. Can be ignored if provided in constructor
    • org? string The Organization ID or slug. If not provided, the request will go to your sandbox account.
    • logicFunction { name: string; description?: string; enabled?: boolean; source: { type: "JavaScript"; code: string; }; logic_triggers?: object[]; api_username?: string; } The logic function object containing the function details.
      • logicFunction.name string
      • logicFunction.description? string
      • logicFunction.enabled? boolean
      • logicFunction.source { type: "JavaScript"; code: string; }
      • logicFunction.source.type "JavaScript"
      • logicFunction.source.code string
      • logicFunction.logic_triggers? object[]
      • logicFunction.api_username? string
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<{ logic_function: LogicFunction; }>> A promise that resolves to the created logic function data.

getLogicFunction

Defined in: Particle.ts:2216

Get a logic function in the specified organization or sandbox by logic function ID.

Parameters

  • options GetLogicFunctionOptions The options for the logic function.

Returns Promise<JSONResponse<{ logic_function: LogicFunction; }>> A promise that resolves to the specified logic function data.

updateLogicFunction

Defined in: Particle.ts:2240

Updates an existing logic function in the specified organization or sandbox using the provided function data.

If you include an id on a logic trigger, it will update the logic trigger in place.

Parameters

  • options The options for updating the logic function.
    • auth? string The access token. Can be ignored if provided in constructor
    • org? string The Organization ID or slug. If not provided, the request will go to your sandbox account.
    • logicFunctionId string The ID of the logic function to update.
    • logicFunction { name?: string; description?: string; enabled?: boolean; source?: { type: "JavaScript"; code: string; }; logic_triggers?: object[]; } The logic function object containing the logic function details.
      • logicFunction.name? string
      • logicFunction.description? string
      • logicFunction.enabled? boolean
      • logicFunction.source? { type: "JavaScript"; code: string; }
      • logicFunction.source.type "JavaScript"
      • logicFunction.source.code string
      • logicFunction.logic_triggers? object[]
    • headers? Record<string, string> Key/Value pairs like { 'X-FOO': 'foo', X-BAR: 'bar' } to send as headers.
    • context? { tool?: ToolContext; project?: ProjectContext; } Request context.
      • context.tool? ToolContext
      • context.project? ProjectContext

Returns Promise<JSONResponse<{ logic_function: LogicFunction; }>> A promise that resolves to the updated logic function data.

deleteLogicFunction

Defined in: Particle.ts:2262

Deletes a logic function in the specified organization or sandbox by logic function ID.

Parameters

  • options DeleteLogicFunctionOptions The options for deleting the logic function.

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listLogicFunctions

Defined in: Particle.ts:2283

Lists all logic functions in the specified organization or sandbox.

Parameters

  • options ListLogicFunctionsOptions The options for listing logic functions.

Returns Promise<JSONResponse<{ logic_functions: LogicFunction[]; }>> A promise that resolves to an array of logic functions data.

listLogicRuns

Defined in: Particle.ts:2307

Lists all logic runs for the specified logic function in the specified organization or sandbox.

Parameters

  • options ListLogicRunsOptions The options for the request.

Returns Promise<JSONResponse<{ logic_runs: LogicRun[]; }>> A promise that resolves to an array of logic run data.

getLogicRun

Defined in: Particle.ts:2329

Retrieves a logic run by its ID for the specified logic function in the specified organization or sandbox.

Parameters

  • options GetLogicRunOptions The options for the request.

Returns Promise<JSONResponse<{ logic_run: LogicRun; }>> A promise that resolves to an array of logic run data for the specified logic run ID.

getLogicRunLogs

Defined in: Particle.ts:2351

Retrieves the logs for a logic run by its ID for the specified logic function in the specified organization or sandbox.

Parameters

  • options GetLogicRunLogsOptions The options for the request.

Returns Promise<JSONResponse<{ logs: LogicRunLog[]; }>> A promise that resolves to the logs for the specified logic run ID.

createLedger

Defined in: Particle.ts:2372

Creates a new ledger definition in the specified organization or sandbox.

Parameters

  • options CreateLedgerOptions The options for creating the ledger definition.

Returns Promise<JSONResponse<LedgerDefinition>> A promise that resolves with the response data

getLedger

Defined in: Particle.ts:2394

Get a ledger definition in the specified organization or sandbox by ledger name.

Parameters

  • options GetLedgerOptions The options for the ledger definition.

Returns Promise<JSONResponse<LedgerDefinition>> A promise that resolves with the response data

updateLedger

Defined in: Particle.ts:2416

Updates an existing ledger definition in the specified organization or sandbox.

Parameters

  • options UpdateLedgerOptions The options for updating the ledger definition.

Returns Promise<JSONResponse<LedgerDefinition>> A promise that resolves with the response data

archiveLedger

Defined in: Particle.ts:2438

Archives a ledger definition in the specified organization or sandbox by ledger name.

Parameters

  • options ArchiveLedgerOptions The options for archiving the ledger definition.

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

Scope

Defined in: Particle.ts:2436

Type: "Owner" | "Product" | "Device"

listLedgers

Defined in: Particle.ts:2466

Lists all ledger definitions in the specified organization or sandbox.

Parameters

  • options ListLedgersOptions The options for listing ledger definitions.

Returns Promise<JSONResponse<{ ledger_definitions: LedgerDefinition[]; }>> A promise that resolves to an array of ledger definition data.

getLedgerInstance

Defined in: Particle.ts:2494

Get ledger instance data.

Parameters

  • options GetLedgerInstanceOptions The options for the ledger instance.

Returns Promise<JSONResponse<LedgerInstance>> A promise that resolves with the response data

SetMode

Defined in: Particle.ts:2492

Type: "Replace" | "Merge"

setLedgerInstance

Defined in: Particle.ts:2522

Set ledger instance data.

Parameters

  • options SetLedgerInstanceOptions The options for updating the ledger instance.

Returns Promise<JSONResponse<LedgerInstance>> A promise that resolves with the response data

deleteLedgerInstance

Defined in: Particle.ts:2548

Delete a ledger instance in the specified organization or sandbox by ledger name.

Parameters

  • options DeleteLedgerInstanceOptions The options for archiving the ledger instance.

Returns Promise<JSONResponse<OKResponse>> A promise that resolves with the response data

listLedgerInstances

Defined in: Particle.ts:2571

Lists ledger instances in the specified organization or sandbox.

Parameters

  • options ListLedgerInstancesOptions The options for listing ledger instances.

Returns Promise<JSONResponse<LedgerInstanceListResponse>> A promise that resolves with the response data

listLedgerInstanceVersions

Defined in: Particle.ts:2599

List ledger instance versions

Parameters

  • options ListLedgerInstanceVersionsOptions The options for the ledger instance.

Returns Promise<JSONResponse<LedgerVersionListResponse>> A promise that resolves with the response data

getLedgerInstanceVersion

Defined in: Particle.ts:2626

Get specific ledger instance version

Parameters

  • options GetLedgerInstanceVersionOptions The options for the ledger instance.

Returns Promise<JSONResponse<LedgerInstance>> A promise that resolves with the response data

listDeviceOsVersions

Defined in: Particle.ts:2649

List Device OS versions

Parameters

  • options ListDeviceOsVersionsOptions Options for this API call

Returns Promise<JSONResponse<DeviceOsVersion[]>> A promise that resolves with the response data

getDeviceOsVersion

Defined in: Particle.ts:2678

Get a specific Device OS version

Parameters

  • options GetDeviceOsVersionOptions Options for this API call

Returns Promise<JSONResponse<DeviceOsVersion>> A promise that resolves with the response data

listEnvVars

Defined in: Particle.ts:2703

List environment variables for the given scope.

Parameters

  • options ListEnvVarsOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsResponse>> A promise that resolves with the env vars data

updateEnvVars

Defined in: Particle.ts:2725

Bulk update environment variables with set/unset operations.

Parameters

  • options UpdateEnvVarsOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsResponse>> A promise that resolves with the updated env vars data

setEnvVar

Defined in: Particle.ts:2749

Set a single environment variable.

Parameters

  • options SetEnvVarOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsResponse>> A promise that resolves with the updated env vars data

deleteEnvVar

Defined in: Particle.ts:2772

Delete a single environment variable.

Parameters

  • options DeleteEnvVarOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsResponse>> A promise that resolves with the updated env vars data

renderEnvVars

Defined in: Particle.ts:2793

Get the rendered (flattened) environment variables for the given scope.

Parameters

  • options RenderEnvVarsOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsRenderResponse>> A promise that resolves with the rendered env vars

reviewEnvVarsRollout

Defined in: Particle.ts:2814

Review the pending environment variables rollout changes.

Parameters

  • options ReviewEnvVarsRolloutOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsRolloutResponse>> A promise that resolves with the rollout diff

startEnvVarsRollout

Defined in: Particle.ts:2836

Start rolling out environment variables to devices.

Parameters

  • options StartEnvVarsRolloutOptions Options for this API call

Returns Promise<JSONResponse<EnvVarsRolloutStartResponse>> A promise that resolves with success status

setDefaultAuth

Defined in: Particle.ts:2849

Set default auth token that will be used in each method if auth is not provided

Parameters

  • auth string The access token

Returns void

Throws

When not auth string is provided

get

get<T>(params: GetHeadOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2906

Make a GET request

Type Parameters
T

T = object

Parameters

  • params GetHeadOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

head<T>(params: GetHeadOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2922

Make a HEAD request

Type Parameters
T

T = object

Parameters

  • params GetHeadOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

post

post<T>(params: MutateOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2938

Make a POST request

Type Parameters
T

T = object

Parameters

  • params MutateOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

put

put<T>(params: MutateOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2955

Make a PUT request

Type Parameters
T

T = object

Parameters

  • params MutateOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

patch

patch<T>(params: MutateOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2971

Make a PATCH request

Type Parameters
T

T = object

Parameters

  • params MutateOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

delete

delete<T>(params: MutateOptions): Promise<JSONResponse<T>>

Defined in: Particle.ts:2987

Make a DELETE request

Type Parameters
T

T = object

Parameters

  • params MutateOptions

Returns Promise<JSONResponse<T>> A promise that resolves with the response data

request

Defined in: Particle.ts:3008

Parameters

  • args AgentRequestOptions An obj with all the possible request configurations

Returns Promise<RequestResponse> A promise that resolves with the response data