Skip to content

API

airvpn.api

An interface for AirVPN's REST API

AirAPI

Main entry point for interacting with the AirVPN API.

Provides access to all available services (devices, DNS lists, config generator, network status, user info, and IP lookup) as lazily-created, cached properties, plus convenience methods for one-off actions like sending notifications and disconnecting sessions.

Attributes:

Name Type Description
devices Devices

The devices service, created and cached on first access.

dns_lists DnsLists

The DNS lists service, created and cached on first access.

generator Generator

The config generator service, created and cached on first access.

status Status

The network status service, created and cached on first access.

userinfo UserInfo

The user info service, created and cached on first access.

whatismyip WhatIsMyIp

The IP lookup service, created and cached on first access.

devices: Devices property

The devices service

dns_lists: DnsLists property

The DNS lists service

generator: Generator property

The config generator service

notification: Notification property

The notification service

status: Status property

The network status service

userinfo: UserInfo property

The user info service

whatismyip: WhatIsMyIp property

The IP lookup service

disconnect(server: Server | str = None, device: Device = None, device_id: str = None) -> int

Requests a disconnection. If none of the filter parameters is specified, disconnect all sessions of the user.

Access type

User-specific, API KEY required.

Parameters:

Name Type Description Default
server Server | str

A Server object or a server's public name to disconnect from

None
device Device

A Device object to disconnect; its id is used if device_id is not explicitly provided.

None
device_id str

ID of the device to disconnect. Ignored if device is provided.

None

Returns:

Type Description
int

Sessions disconnected.

Raises:

Type Description
APIKeyRequired

If you don't set your api_key.

APIError

If the API fails.

RateLimited

If too many requests go through.

get_service(service: str) -> Devices | DnsLists | Generator | Status | UserInfo | WhatIsMyIp | Notification

Instantiate a named service class, enforcing its API key requirement.

Parameters:

Name Type Description Default
service str

The service name (e.g. "devices", "status"), matched case-insensitively against the registered service classes.

required

Returns:

Type Description
Devices | DnsLists | Generator | Status | UserInfo | WhatIsMyIp | Notification

An instance of the requested service class.

Raises:

Type Description
RateLimited

If too many requests go through.

APIError

If the service request results in an error.

InvalidService

If the service name is invalid.

APIKeyRequired

If the service requires an API key and none was provided.