A Python package to interact with the Outline VPN Server API
Project description
PyOutlineAPI
pyoutlineapi
is a Python package designed to interact with the Outline VPN Server API, providing robust data
validation through Pydantic models. This ensures reliable and secure API interactions, making it an excellent choice for
integrating with bots and other automated systems that require accurate and secure communication.
Features
- Server Management: Retrieve server information, update hostnames, manage ports, and more.
- Access Key Management: Create, list, rename, and delete access keys, as well as set data limits.
- Metrics: Enable or disable metrics sharing and retrieve data transfer metrics.
- Experimental Endpoints: Access and manage experimental features of the Outline Server API.
Quick Start
To get started with pyoutlineapi
, follow these steps:
- Install the package using pip or Poetry.
- Initialize the
PyOutlineWrapper
client with your Outline VPN server URL and certificate fingerprint. - Use the provided methods to interact with the server and access keys.
See the examples below for more detailed information.
Installation
You can install PyOutlineAPI via PyPI using pip:
pip install pyoutlineapi
Or via Poetry:
poetry add pyoutlineapi
Basic Operations
Initialize the Client
from pyoutlineapi.client import PyOutlineWrapper
from pyoutlineapi.models import DataLimit
# Initialize the API client
api_url = "https://your-outline-url.com"
cert_sha256 = "your-cert-sha256-fingerprint"
# Set "verify_tls" to False if using a self-signed certificate.
# Set "json_format" to True if answers need to be returned in JSON format. Defaults to False - Pydantic models will be returned.
api_client = PyOutlineWrapper(api_url=api_url, cert_sha256=cert_sha256, verify_tls=False, json_format=True)
Retrieve Server Information
server_info = api_client.get_server_info()
print("Server Information:", server_info)
Create a New Access Key
# Create a new access key with default values
new_access_key = api_client.create_access_key()
# Create a new access key with custom values
new_access_key = api_client.create_access_key(name="my_access_key", password="secure_password", port=8080)
print("New Access Key:", new_access_key)
Delete Access Key
success = api_client.delete_access_key("example-key-id")
print("Access Key Deleted Successfully" if success else "Failed to Delete Access Key")
Additional Functions
Update Server Port
update_success = api_client.update_server_port(9090)
print("Server Port Updated:", update_success)
Set Data Limit for an Access Key
data_limit = api_client.set_access_key_data_limit("example-key-id", DataLimit(bytes=50000000))
print("Data Limit Set:", data_limit)
Retrieve Metrics
metrics_data = api_client.get_metrics()
print("Metrics Data:", metrics_data)
Contributing
We welcome contributions to PyOutlineAPI! Please follow the guidelines outlined in the CONTRIBUTING.md file.
License
PyOutlineAPI is licensed under the MIT License. See the LICENSE file for more details.
Frequently Asked Questions (FAQ)
How to use self-signed certificates?
Set the verify_tls
parameter to False
when initializing the client.
How to change the response format to Pydantic models?
Set the json_format
parameter to False
when initializing the client if you need to receive responses in Pydantic
models.
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
Built Distribution
File details
Details for the file pyoutlineapi-0.1.3.tar.gz
.
File metadata
- Download URL: pyoutlineapi-0.1.3.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10fc29d483bfe81a18f929d71ffd2c3236bbabf4aa93a09044fa34ad7c9a872a |
|
MD5 | 5bb7749a405d78440e8f5cae75190b8b |
|
BLAKE2b-256 | 62393c6e422b6ae7bf53ef6dfbad55551b8c46773ac7e2a4f4d9eca91e17f06a |
File details
Details for the file pyoutlineapi-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: pyoutlineapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5093cbcb1a4e1726f0a5b823290df072344e10ff81ce3581940c4da09be83e0 |
|
MD5 | 0fe2a77137bc1a8d073b9a0dc8018466 |
|
BLAKE2b-256 | f92d7ce20c11eb59f293faac196847fd649313b0c4bdb43f03442843859cdb08 |