# portainer-api-client

> Node.js client for interacting with the Portainer HTTP API

Latest version **0.2.0** (published 2025-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install portainer-api-client
pnpm add portainer-api-client
yarn add portainer-api-client
bun add portainer-api-client
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2025-06-11 |
| First published | 2018-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | John Murphy-Teixidor |
| Maintainers | johnvmt |

## Links

- npm: https://www.npmjs.com/package/portainer-api-client
- Repository: https://github.com/johnvmt/portainer-api-client
- Homepage: https://github.com/johnvmt/portainer-api-client#readme
- Issues: https://github.com/johnvmt/portainer-api-client/issues
- npm.io page: https://npm.io/package/portainer-api-client

## Dependencies (1)

- [jwt-decode](https://npm.io/package/jwt-decode.md) ^4.0.0

## Recent versions

- 0.2.0 (latest) — 2025-06-11
- 0.1.0 — 2024-12-04
- 0.0.2 — 2018-11-06
- 0.0.1 — 2018-11-06

## README

# Portainer API Client

Make requests against a Portainer API, authenticating with username/password or key

## Example: Get a container's status with username/password auth

	import PortainerClient from 'portainer-api-client';
	
	const portainerURL = process.env.PORTAINER_URL;
	const portainerUsername = process.env.PORTAINER_USERNAME;
	const portainerPassword = process.env.PORTAINER_PASSWORD;
	
	const portainer = new PortainerClient({
        url: portainerURL,
        username: portainerUsername,
        password: portainerPassword
    });
	
    const container = await portainer.callAPIWithKey('GET', '/api/endpoints/1/docker/containers/my_container_name/json');
    console.log(`Container's status is ${container.State?.Status}`);

## Example: Get a container's status with key auth

	import PortainerClient from 'portainer-api-client';
	
	const portainerURL = process.env.PORTAINER_URL;
	const portainerAPIKey = process.env.PORTAINER_API_KEY;
	const portainerPassword = process.env.PORTAINER_PASSWORD;
	
	const portainer = new PortainerClient({
        url: portainerURL,
        key: portainerAPIKey
    });
	
    const container = await portainer.callAPIWithKey('GET', '/api/endpoints/1/docker/containers/my_container_name/json');
    console.log(`Container's status is ${container.State?.Status}`);

## Example: Update a registry's password with username/password auth

	import PortainerClient from 'portainer-api-client';
	
	const portainerURL = process.env.PORTAINER_URL;
	const portainerUsername = process.env.PORTAINER_USERNAME;
	const portainerPassword = process.env.PORTAINER_PASSWORD;
	
    const portainer = new PortainerClient({
        url: portainerURL,
        username: portainerUsername,
        password: portainerPassword
    });
	
	let registries = await portainer.callAPIWithKey('get', '/api/registries');
	registry = registries[0]
	
	registry.Username = 'newusername';
	registry.Password = 'newusername';

	await portainer.callAPIWithKey('PUT', `/api/registries/${registry.Id}`, registry);

## TODOs

* Convenience functions
* Documentation

---
_Source: https://npm.io/package/portainer-api-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
