0.1.0 • Published 7 months ago

portainer-api-client v0.1.0

Weekly downloads
42
License
MIT
Repository
github
Last release
7 months ago

Portainer API Client

Example: Get a container's status

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(portainerUrl, portainerUsername, 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: Update a registry's password

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(portainerUrl, portainerUsername, 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
0.1.0

7 months ago

0.0.2

7 years ago

0.0.1

7 years ago