npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pritunl

v0.0.4

Published

Node.js Pritunl Api

Downloads

83

Readme

pritunl

NPM

Node.js Pritunl API

Install

$ npm install --save pritunl

Usage

To start a new Pritunl instance:

var Pritunl = require('pritunl');
 
var pritunl = new Pritunl({
  baseurl: <PRITUNL_SERVER_BASE_URL>,
  api_token: <API_TOKEN>,
  api_secret: <API_SECRET>
});

API

Method request()

In Pritunl, all API requests must be signed with the API token and secret. The API token and secret can be found in the Settings dialog, Pritunl admin page.

Read more: Pritunl API - Authentication

Helper object Global

pritunl.global.log

Returns a list of server log entries sorted by time.

pritunl.global.log().then(function(entries) {
  console.log('Log entries: %s', JSON.stringify(entries, null, 2));  
});

Read more: Pritunl API - GET /log

pritunl.global.ping

Server healthcheck.

pritunl.global.ping().then(function(result) {
  console.log('Ping status code: %s', JSON.stringify(result, null, 2));  
});

Read more: Pritunl API - GET /ping

pritunl.global.status

Returns general information about the pritunl server.

pritunl.global.status().then(function(status) {
  console.log('Server status: %s', JSON.stringify(status, null, 2));  
});

Read more: Pritunl API - GET /status

Helper object Organization

pritunl.organization.list

Returns a list of organizations on the server sorted by name.

pritunl.organization.list().then(function(result) {
  console.log('Organization list: %s', JSON.stringify(result, null, 2));
});

Read more: Pritunl API - GET /organization

pritunl.organization.get

Returns an organization.

var org_id = '<change_your_organization_id>';
pritunl.organization.get(org_id).then(function(item) {
  console.log('Organization item:%s: %s', org_id, JSON.stringify(item, null, 2));  
});

Read more: Pritunl API - GET /organization/:org_id

pritunl.organization.create

Create a new organization.

Promise.resolve().then(function() {
  return pritunl.organization.create({name: 'org_no_1'});
}).then(function() {
  return pritunl.organization.create({name: 'org_no_2'});
}).then(function() {
  return pritunl.organization.list();
}).then(function(organizations) {
  console.log('Organizations: %s', JSON.stringify(organizations, null, 2));
});

Read more: Pritunl API - POST /organization

pritunl.organization.update

Rename an existing organization.

Read more: Pritunl API - PUT /organization

pritunl.organization.delete

Delete an existing organization.

Promise.resolve().then(function() {
  return pritunl.organization.create({name: 'org_no_1'});
}).then(function() {
  return pritunl.organization.create({name: 'org_no_2'});
}).then(function() {
  return pritunl.organization.list();
}).then(function(organizations) {
  console.log('Organizations: %s', JSON.stringify(organizations, null, 2));
  return organizations;
}).then(function(organizations) {
  return pritunl.organization.delete(organizations[0].id);
}).then(function() {
  return pritunl.organization.list();
}).then(function(organizations) {
  console.log('Organizations: %s', JSON.stringify(organizations, null, 2));
  return organizations;
}).then(function(organizations) {
  return pritunl.organization.delete(organizations[0].id);
});

Read more: Pritunl API - DELETE /organization/:organization_id

Helper object User

pritunl.user.list

Returns a list of users in an organization sorted by name.

var org_id = '<your_organization_id>';
pritunl.user.list(org_id).then(function(result) {
  console.log('Organization list: %s', JSON.stringify(result, null, 2));
}); 

Read more: Pritunl API - GET /user/:organization_id

pritunl.user.get

Returns a user from an organization.

var org_id = '<your_organization_id>';
var user_id = '<your_user_id>';
pritunl.user.get(org_id, user_id).then(function(user) {
  console.log('User: %s', JSON.stringify(user, null, 2));
}); 

Read more: Pritunl API - GET /user/:organization_id

pritunl.user.create

Create a new user in an organization. An array of users can be sent for bulk adding users.

Promise.resolve().then(function() {
  return pritunl.organization.create({name: 'org_example'});
}).then(function() {
  return pritunl.organization.list();
}).then(function(organizations) {
  console.log('Organizations: %s', JSON.stringify(organizations, null, 2));
});

Read more: Pritunl API - POST /user/:organization_id

pritunl.user.update

Rename or disabled an existing user in an organization. Disabling will also disconnect the user.

Read more: Pritunl API - PUT /user/:organization_id/:user_id

pritunl.user.delete

Delete an existing user in an organization, this will disconnect the user.

pritunl.user.delete('<organization_id>', '<user_id>').then(function() {
  console.log('User has been successfully deleted');
}, function(statusCode) {
  console.log('Failed to delete user: %s', statusCode);
});

Read more: Pritunl API - DELETE /user/:organization_id/:user_id