optimihost API
An easy to use Python wrapper for the OptimiHost API.
Installing
To install with pip:
pip install optimihost
Exploring the API
In addition to the documentation you can explore the interface in an
interactive Python interpreter using built-ins like dir() and the
__doc__ attribute as shown below.
from optimihost import Connect
api = Connect('<api_key>')
[i for i in dir(api.client.servers) if not i.startswith('_')]
# ['account', 'backups', 'databases', 'files', 'get_server', 'get_server_utilization', 'list_permissions', 'list_servers', 'network', 'schedules', 'send_console_command', 'send_power_action', 'servers', 'settings', 'startup', 'users']
[i for i in dir(api.client.servers.settings) if not i.startswith('_')]
# ['reinstall_server', 'rename_server']
print(api.client.servers.settings.rename_server.__doc__)
# Renames the server.
# Args:
# server_id(str): Server identifier (abbreviated UUID)
# name(str): New name for the server
Client API
The Client API or Account API is accessed by users of the Pterodactyl panel. Below is the layout of the Client API namespace.
api.client.account
api.client.servers
api.client.servers.backups
api.client.servers.databases
api.client.servers.files
api.client.servers.network
api.client.servers.schedules
api.client.servers.settings
api.client.servers.startup
api.client.servers.users
A full list of methods available can be found in the [documentation][docs].
Below are examples of how you might get information about your servers.
from optimihost import Connect
# Create a client to connect to the panel and authenticate with your API key.
api = Connect('MySuperSecretApiKey')
# Get a list of all servers the user has access to
my_servers = api.client.servers.list_servers()
# Get the unique identifier for the first server.
srv_id = my_servers[0]['attributes']['identifier']
# Check the utilization of the server
srv_utilization = api.client.servers.get_server_utilization(srv_id)
print(srv_utilization)
# Turn the server on.
api.client.servers.send_power_action(srv_id, 'start')
Metadata
Release files for optimihost 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| optimihost-0.2.0.tar.gz | 21.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optimihost-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.6 kB
Release files / optimihost-0.2.0.tar.gz
| Download URL | optimihost-0.2.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cb8b876f2dee5b98871b59877f75d2208d8896dcdc31830a93f2512eaeae8cf
|
|
BLAKE2b-256 checksum How to use checksums |
cc391e248edc2bacec169408fec31c7b1ca039fc1c91c50cc850a1a6c240762a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / optimihost-0.2.0-py3-none-any.whl
| Download URL | optimihost-0.2.0-py3-none-any.whl |
|---|---|
| Size | 30.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c27b87cd37c2328122d8b3a2c0fbab00a1292a865e1e8d65f479421bb68999e3
|
|
BLAKE2b-256 checksum How to use checksums |
b1052cda18fd1651dab5c24c4ef90be4e1473f8ce50fac928d96afee53aa7d80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|