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
muslnode 18–226 runs
build_error
glibcnode 18–226 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?fixUse Particle Cloud API directly or alternative authentication flow.
affects: >=11.0.0 <12.0.0
breakingQuery string access_token parameter is no longer supported.fixPass 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.fixUse 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
fixRun `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)
fixUse `import Particle from 'particle-api-js'` then `new Particle()`
Audit
Dependencies
form-datarequiredUsed for multipart/form-data requests (e.g., firmware uploads)