Registry / http-networking / particle-api-js

particle-api-js

JSON →
library12.0.2jsnpmunverified

JavaScript library for the Particle Cloud API, usable in Node.js (v16+) and browser environments. Current stable version is v12.0.2, released via npm. Actively maintained with releases every few months. Written in TypeScript with full type declarations. Covers all Particle IoT device interactions: authentication, device listing, variable/function access, event streaming, firmware management, and more. Differentiates from raw fetch/axios by wrapping the entire Particle REST API with typed request options and responses, handling authentication and pagination internally. Ships both ESM and UMD builds (CDN via jsDelivr). Major v12.0.0 was a TypeScript migration; v11.0.0 removed token list/delete APIs and query access_token support.

npm install particle-api-js
INSTALL
IMPORT
SIG · PARTICLE-API-JS
P
particle-api-js
http-networkingjavascriptv12.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Particle
import Particle from 'particle-api-js'
const { Particle } = require('particle-api-js')
Default export is the Particle class. Named export for class was removed in v12.0.0 TypeScript migration.
DeviceInfo
import type { DeviceInfo } from 'particle-api-js'
import { DeviceInfo } from 'particle-api-js'
Type imports should use `import type` to avoid runtime inclusion. Available since v12.0.0.
LoginResponse
import type { LoginResponse } from 'particle-api-js'

Shows how to instantiate Particle client, authenticate via login, list devices, and fetch a single device with full TypeScript typing.

import Particle from 'particle-api-js'; import type { DeviceInfo, LoginResponse } from 'particle-api-js'; const particle = new Particle({ auth: process.env.PARTICLE_TOKEN ?? '' }); async function listDevices() { try { const response = await particle.listDevices(); console.log('Devices:', response.body); } catch (error) { console.error('Error:', error); } } async function loginAndCall() { const loginResp = await particle.login({ username: process.env.EMAIL ?? '', password: process.env.PASSWORD ?? '' }); console.log('Token:', loginResp.body.access_token); // Re-create client with new token const particleAuthed = new Particle({ auth: loginResp.body.access_token }); const device = await particleAuthed.getDevice({ deviceId: 'abc123' }); console.log('Device name:', device.body.name); } listDevices();
Debug
Known issues
deprecateddeleteAccessToken and listAccessTokens methods are deprecated in v11.0.0 and removed from v12?
fix
Use Particle Cloud API directly or alternative authentication flow.
affects: >=11.0.0 <12.0.0
breakingQuery string access_token parameter is no longer supported.
fix
Pass token via Authorization header (handled automatically via constructor auth option).
affects: >=11.0.0
gotchaIn browsers, using the CDN builds (<script> tag) exposes global variable `Particle` but TypeScript types are not available.
fix
Use ES module import from npm for typed usage.
affects: >=8.0.0
Errors
Common errors & fixes
Error: Cannot find module 'particle-api-js'
Package not installed via npm
fix
Run `npm install particle-api-js` or `yarn add particle-api-js`
TypeError: particle.listDevices is not a function
Incorrect import (likely named import instead of default)
fix
Use `import Particle from 'particle-api-js'` then `new Particle()`
Upgrade
Version history
12.0.2latest on npm
Audit
Dependencies
form-datarequiredUsed for multipart/form-data requests (e.g., firmware uploads)
Agent activity
16 hits · last 30 days
node
12
Amazon
1
Resources
particle-api-js — npm install particle-api-js · libregistry