A node Api Manager for Portainer

Usage no npm install needed!

<script type="module">
  import apiPortainer from 'https://cdn.skypack.dev/api-portainer';


Portainer Client

This projects exposes the Portainer API (currently for version 1.20.2) as Promise-based JavaScript functions. Currently, only GET based endpoints are implemented, other ones will follow. If I have enough time and motivation, I will also add an OOP abstraction layer.

The package is written in TypeScript (.d.ts type definitions come bundled with this package) and compiles to ES5.

Table of contents


  • Call Portainer API endpoints using plain JS functions or a class
  • Optional encapsulation of authentication and hostname using the PortainerSession class


Using the plain functions

const host = 'https://myportainerinstance';

async function main() {
    const token = await authenticate(host, 'username', 'password');
    const stacks = await stacks.getAll(host, token);

$ node index.js

Using the PortainerSession class

import PortainerSession from 'portainer-client';

async function main() {
    const portainer = await PortainerSession.create('https://portainer.example.com','username', 'password');

    const stacks = await portainer.getStacks();
$ node index.js