GitHub - admjs/njord

1 min read Original article ↗

Njord Python Package

Overview

The njord python package provides a convenient wrapper to programmatically working with NordVPN servers on Mac/Linux via OpenVPN.

Prerequisites

  • sudo
  • openvpn

Because njord relies on sudo and openvpn, it only works on OSX (including Apple silicone) and Linux. Linux is currently untested. Nord has an official client that may better serve your needs on Linux. Windows isn't supported.

Installing OpenVPN

OSX

$ brew install openvpn

Ubuntu

$ sudo apt-get install openvpn

Installation

$ pip install njord

Usage

Authentication

Authentication is handled via service credentials. Generate these via your Nord account at Services > NordVPN > Manual Setup

Copy the service credentials username and password. It's reccomended that you use a .env file for storing them. Njord will check for a .env file on initialization as well as os env variables. Authentication can also be done explicitly during init.

# .env
NORD_USER=xxxxxxxxxxxxx
NORD_PASSSWORD=xxxxxxxxxxx
import njord

# Using .env file or os env
client = njord.Client()

# Explicit
client = njord.Client(user="xxxxxxxx", password="xxxxxxxxx")

Connecting & Disconnecting

import njord
client = njord.Client()
client.connect()
>> Connected to us10086.nordvpn.com
client.protected()
>> True
vpn.disconnect()
vpn.protected()
>> False