Skip to main content

Pritunl API Client for Python

Project description

Pritunl API Client for Python 3

This is a simple Pritunl API Client written in Python 3.

You need to refer to Pritunl API Documentation to understand how to use this. This API client uses almost the same command as the API Handlers.


Install the published package using pip from our PyPI project repository.

pip install pritunl-api

Beyond the core API client library, we also added the executable distribution in this project. Add extra cli during the PIP installation to enable the CLI feature.

pip install pritunl-api[cli]

Proceed to the CLI Usage for the syntax of the complete commands.

API Usage

import os
from pritunl_api import Pritunl

pritunl = Pritunl(

# Your Pritunl API Client Object is now ready to use!


  • Example 1:

    (in source) GET /server

  • Example 2:

    (in source) PUT /server/:server_id/organization/:organization_id

    pritunl.server.put(srv_id='', org_id='')
  • Example 3:

    (in source) DELETE /user/:organization_id/:user_id

    pritunl.user.delete(org_id='', usr_id='')
  • Example 4:

    (in source) POST /server**{
      'name': 'new server name'})

    * If there is data available, you must pass it through the data parameter.

    * The command above works well because there are templates available for creating a new server._

  • Example 5:

    (in source) PUT /user/:organization_id/:user_id

    pritunl.user.put(org_id='', usr_id='', data={
      'name': 'modified org name',
      'disabled': True})

CLI Usage

Before using the CLI, provide the Pritunl API URL and Administrative Credential in our Environment Variables.

export PRITUNL_BASE_URL="https://vpn.domain.tld/"

Available Commands

As of this period of development, the feature is limited.

To show the available commands, use the help option.

pritunl-api-cli --help
Usage: pritunl-api-cli [OPTIONS] COMMAND [ARGS]...

  --help  Show this message and exit.


For available command options and syntax, use the feature command help option.

pritunl-api-cli create-user --help
Usage: pritunl-api-cli create-user [OPTIONS]

  --org-name TEXT
  --user-name TEXT
  --user-email TEXT
  --from-csv-file PATH
  --help                Show this message and exit.

Create User

Example 1: Create a Single User

pritunl-api-cli create-user \
  --org-name develop-network \
  --user-name developer_1 \
  --user-email developer_1@domain.tld

Example 2: Create Users from CSV

pritunl-api-cli create-user \
  --from-csv-file ./users.csv

Delete User

pritunl-api-cli delete-user \
  --org-name develop-network \
  --user-name developer_1

Get User Information or Generate a new Key

pritunl-api-cli get-user \
  --org-name develop-network \
  --user-name developer_1

Or get only the profile key

pritunl-api-cli get-user \
  --org-name develop-network \
  --user-name developer_1 \

Update a User

To disable a user

pritunl-api-cli update-user \
  --org-name develop-network \
  --user-name developer_1 \

To enable a user

pritunl-api-cli update-user \
  --org-name developer-network \
  --user-name developer_1 \

API Development

Using Virtual Environment

pip install -e .

Include REPL Tools

pip install -e .[repl]

Using Docker Environment

Building a Development Container

docker buildx build . \
  --progress plain \
  --file dev.Dockerfile \
  --tag pritunl-api:development

Running a Development Container

docker run --rm -it \
  --volume $(PWD):/pritunl-api \
  --env-file .env \
  pritunl-api:development poetry shell

This API client is not fully complete. Some features are missing, feel free to fork and pull requests to add new features.

Tested working on Pritunl v1.30.3354.99.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pritunl_api-1.1.1.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

pritunl_api-1.1.1-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page