Skip to main content

API For optimihost

Project description

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')

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

optimihost-0.2.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optimihost-0.2.0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file optimihost-0.2.0.tar.gz.

File metadata

  • Download URL: optimihost-0.2.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for optimihost-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3cb8b876f2dee5b98871b59877f75d2208d8896dcdc31830a93f2512eaeae8cf
MD5 ee731ce352b5da3e2d1647ea0873dbbe
BLAKE2b-256 cc391e248edc2bacec169408fec31c7b1ca039fc1c91c50cc850a1a6c240762a

See more details on using hashes here.

File details

Details for the file optimihost-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: optimihost-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for optimihost-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c27b87cd37c2328122d8b3a2c0fbab00a1292a865e1e8d65f479421bb68999e3
MD5 788cc5ebc2abec3ed7efdf4be5dd6917
BLAKE2b-256 b1052cda18fd1651dab5c24c4ef90be4e1473f8ce50fac928d96afee53aa7d80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page