AirVPN
airvpn
Python API for interacting with AirVPN.
This module provides a set of Python interfaces for working with AirVPN's services, covering three main components:
- AirClient: A client for AirVPN's encrypted bootstrap API, used to retrieve server and configuration data before authentication.
- AirAPI: A wrapper around AirVPN's official REST API (https://airvpn.org/apisettings/), used for authenticated operations such as managing devices and API keys.
- WebClient: A client that interacts directly with the AirVPN website, handling tasks not exposed through the official API.
AirVPN
High-level entry point for interacting with AirVPN.
Can be constructed with credentials to log in to the website and
initialize both client and api, or with an existing API key secret
to initialize api only, without touching the website at all. Can also
be constructed with neither, deferring authentication until login()
or init_api() is called explicitly. When logging in with credentials,
the account is guaranteed to have at least one API key (creating one if
necessary), and that key is used to initialize api automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
The AirVPN account username. If provided,
|
None
|
password
|
str
|
The AirVPN account password. Required if
|
None
|
api_key
|
str
|
An existing AirVPN API key secret. If
provided (and |
None
|
session_key
|
str
|
The session key gotten from |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
bootstrap |
AirClient
|
Client for AirVPN's encrypted bootstrap API. |
web |
WebClient
|
Client for interacting with the website. |
api |
AirAPI
|
Authenticated client for AirVPN's official REST API. |
Example
# Log in immediately, with username and password (website + REST API)
vpn = AirVPN("myusername", "mypassword")
vpn.web.user.api.keys
vpn.api.devices
# REST API access only, no website login
vpn = AirVPN(api_key="mysecret")
vpn.api.devices.get("my-device")
# Defer login
vpn = AirVPN()
vpn.login("myusername", "mypassword")
vpn.web.user.api.keys
init_api(api_key: str)
Initialize the AirAPI client directly from an API key secret.
Useful for bypassing login() if an API key is already known.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The AirVPN API key secret. |
required |
login(username: Optional[str] = None, password: Optional[str] = None, remember_me: bool = False, session_key: Optional[str] = None)
Authenticate with the AirVPN website.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Account username or email address. |
None
|
password
|
str
|
Account password. |
None
|
rememeber_me
|
bool
|
Whether or not to store the session's credentials. |
required |
session_key
|
str
|
The value from |
None
|
Raises:
| Type | Description |
|---|---|
LoginError
|
If authentication fails. |