Python AirVPN
A Python wrapper for AirVPN's API.
Note: Docstrings and documentation were AI-assisted. If you spot any errors, please open a PR or an issue.
Installation
From PyPI:
From source:
Interfaces
The library exposes four interfaces, depending on how much control you need:
AirVPN— high-level wrapper; the best starting point for most use cases.AirClient— low-level client for the encrypted bootstrap API.AirAPI— client for AirVPN's authenticated REST API.WebClient— client for AirVPN's website/session-based endpoints.
Quick Start
AirVPN
Log in immediately, by passing credentials on construction. This is the simplest path if you just want to get to work:
import os
from dotenv import load_dotenv
load_dotenv()
from airvpn import AirVPN
vpn = AirVPN(os.getenv("LOGIN"), os.getenv("PASSWORD"))
# Create (or fetch) a device and download a config for it
device = vpn.api.devices.get("test", create=True)
vpn.api.generator.download("config-directory", "earth", device.id)
Defer login, if you need to construct the object before credentials are available (e.g. in a CLI or app that prompts for them later):
from airvpn import AirVPN
vpn = AirVPN()
# ... later, once you have credentials ...
vpn.login(username, password)
print(vpn.client.name)
Skip the web login entirely, if you already have an API key secret saved from a previous session:
import os
from dotenv import load_dotenv
load_dotenv()
from airvpn import AirVPN
vpn = AirVPN(api_key=os.getenv("API_KEY"))
device = vpn.api.devices.get("test", create=True)
Bootstrap
An AirVPN instance always has a bootstrap client available, no login required, for public data like server manifests: