Skip to content

Latest commit

 

History

History
551 lines (330 loc) · 32.8 KB

File metadata and controls

551 lines (330 loc) · 32.8 KB

Particle

src/Particle.js:17-591

Particle Cloud API wrapper.

See https://docs.particle.io/reference/javascript/ for examples of using the Particle class.

Most Particle methods take a single unnamed argument object documented as $0 with key/value pairs for each option.

constructor

src/Particle.js:25-28

Constructor for the Cloud API wrapper.

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

Parameters

  • options Object?= i: Options to be used for all requests (see Defaults)

login

src/Particle.js:37-46

Login to Particle Cloud using an existing Particle acccount.

Parameters

  • $0 Object
    • $0.username String Username for the Particle account
    • $0.password String Password for the Particle account
    • $0.tokenDuration Number?= company name, busi How long the access token should last in seconds

Returns Promise

createUser

src/Particle.js:55-61

Create a user account for the Particle Cloud

Parameters

  • $0 Object
    • $0.username String Email of the new user
    • $0.password String Password
    • $0.accountInfo String Object that contains account information fields such as user real name, company name, business account flag etc

Returns Promise

createShadowUser

src/Particle.js:68-75

Create a shadow user account (two-legged auth) for the Particle Cloud

Parameters

Returns Promise

verifyUser

src/Particle.js:82-86

Verify new user account via verification email

Parameters

  • $0 Object
    • $0.token String the string token sent in the verification email

Returns Promise

resetPassword

src/Particle.js:93-95

Send reset password email for a Particle Cloud user account

Parameters

Returns Promise

removeAccessToken

src/Particle.js:104-108

Revoke an access token

Parameters

  • $0 Object
    • $0.username String Username of the Particle cloud account that the token belongs to.
    • $0.password String Password for the account
    • $0.token String Access token you wish to revoke

Returns Promise

listAccessTokens

src/Particle.js:116-118

List all valid access tokens for a Particle Cloud account

Parameters

Returns Promise

listDevices

src/Particle.js:125-127

List devices claimed to the account

Parameters

Returns Promise

getDevice

src/Particle.js:135-137

Get detailed information about a device

Parameters

Returns Promise

claimDevice

src/Particle.js:145-150

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

Parameters

Returns Promise

removeDevice

src/Particle.js:158-160

Unclaim / Remove a device from your account

Parameters

Returns Promise

renameDevice

src/Particle.js:169-171

Rename a device

Parameters

Returns Promise

getClaimCode

src/Particle.js:179-181

Generate a claim code to use in the device claiming process.

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.iccid String? ICCID of the SIM card used in the Electron

Returns Promise

getVariable

src/Particle.js:201-203

Get the value of a device variable

Parameters

Returns Promise

signalDevice

src/Particle.js:212-216

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

Parameters

Returns Promise

flashDevice

src/Particle.js:226-235

Compile and flash application firmware to a device

Parameters

  • $0 Object
    • $0.deviceId String Device ID or Name
    • $0.files Object Object containing files to be compiled. Keys should be the filenames, and the values should be a path or Buffer of the file contents.
    • $0.targetVersion String? System firmware version to compile against (optional, default latest)
    • $0.auth String String

Returns Promise

flashTinker

src/Particle.js:243-247

Flash the Tinker application to a device

Parameters

Returns Promise

compileCode

src/Particle.js:257-266

Compile firmware using the Particle Cloud

Parameters

  • $0 Object
    • $0.files Object Object containing files to be compiled. Keys should be the filenames, and the values should be a path or Buffer of the file contents.
    • $0.platformId Number? Platform id number of the device you are compiling for. Common values are 0=Core, 6=Photon, 10=Electron.
    • $0.targetVersion String? System firmware version to compile against (optional, default latest)
    • $0.auth String Access Token

Returns Promise

downloadFirmwareBinary

src/Particle.js:274-283

Download a firmware binary

Parameters

  • $0 Object
    • $0.binaryId String Binary ID received from a successful compile call
    • $0.auth String Access Token

Returns Request

sendPublicKey

src/Particle.js:293-301

Send a new device public key to the Particle Cloud

Parameters

  • $0 Object
    • $0.deviceId String Device ID or Name
    • $0.key (String | Buffer) Public key contents
    • $0.algorithm String? Algorithm used to generate the public key. Valid values are rsa or ecc. (optional, default rsa)
    • $0.auth String Access Token

Returns Promise

callFunction

src/Particle.js:311-315

Call a device function

Parameters

Returns Promise

getEventStream

src/Particle.js:327-351

Get a stream of events

Parameters

  • $0 Object
    • $0.deviceId String? Device ID or Name, or mine to indicate only your devices.
    • $0.name String? Event Name
    • $0.org String? Organization Slug
    • $0.product String? Product Slug or Product ID
    • $0.auth String Access Token

Returns Promise If the promise resolves, the resolution value will be an EventStream object that will emit 'event' events, as well as the specific named event.

publishEvent

src/Particle.js:361-367

Publish a event to the Particle Cloud

Parameters

Returns Promise

createWebhook

src/Particle.js:386-394

Create a webhook

Parameters

  • $0 Object
    • $0.deviceId String Device ID or Name
    • $0.name String Webhook name
    • $0.url String URL the webhook should hit
    • $0.requestType String? HTTP method to use (optional, default POST)
    • $0.headers Object? Additional headers to add to the webhook
    • $0.json Object? JSON data
    • $0.query Object? Query string data
    • $0.responseTemplate Object? Webhook response template
    • $0.responseTopic Object? Webhook response topic
    • $0.rejectUnauthorized Boolean? Reject invalid HTTPS certificates
    • $0.webhookAuth Object? HTTP Basic Auth information
    • $0.form Object? Form data
    • $0.auth String Access Token

Returns Promise

deleteWebhook

src/Particle.js:402-404

Delete a webhook

Parameters

Returns Promise

listWebhooks

src/Particle.js:411-413

List all webhooks owned by the account

Parameters

Returns Promise

getUserInfo

src/Particle.js:420-422

Get details about the current user

Parameters

Returns Promise

setUserInfo

src/Particle.js:432-440

Set details on the current user

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.stripeToken String Set user's stripe token for payment
    • $0.accountInfo String Set user's extended info fields (name, business account, company name, etc)
    • $0.password String Change authenticated user password

Returns Promise

listBuildTargets

src/Particle.js:460-466

List valid build targets to be used for compiling

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.onlyFeatured Boolean? Only list featured build targets (optional, default false)

Returns Promise

listLibraries

src/Particle.js:479-488

List firmware libraries

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.page Number Page index (default, first page)
    • $0.limit Number Number of items per page
    • $0.filter String Search term for the libraries
    • $0.sort String Ordering key for the library list
    • $0.architectures Array<String> List of architectures to filter
    • $0.category String Category to filter

Returns Promise

getLibrary

src/Particle.js:497-499

Get firmware library details

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.name String Name of the library to fetch
    • $0.version String Version of the library to fetch (default: latest)

Returns Promise

getLibraryVersions

src/Particle.js:509-514

Firmware library details for each version

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.name String Name of the library to fetch
    • $0.page Number Page index (default, first page)
    • $0.limit Number Number of items per page

Returns Promise

contributeLibrary

src/Particle.js:522-529

Contribute a new library version int the compressed archive

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.archive String Compressed archive file containing the library sources

Returns Promise

deleteLibrary

src/Particle.js:542-544

Delete one version of a library or an entire published library

Parameters

  • $0 Object
    • $0.auth String Access Token
    • $0.name String Name of the library to delete
    • $0.force String Key to force deleting a public library

Returns Promise

downloadFile

src/Particle.js:551-562

Download an external file that may not be on the API

Parameters

Returns Promise Resolves to a buffer with the file data