New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

portainer-api-client

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

portainer-api-client

Node.js client for interacting with the Portainer HTTP API

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
86
-68.38%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 11 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts