Skip to main content

Command-line interface for DirectAdmin written in Python — provides API-driven automation and utilities for server, user, domain, and DNS management.

Project description

DirectAdminAPIClient

A lightweight Python client for the DirectAdmin HTTP API. DirectAdminAPIClient (which extends BaseDirectAdminAPIClient) provides convenience methods for managing admins, resellers, users, packages and account actions.

Highlights:

  • Simple programmatic access to common DirectAdmin endpoints
  • Thin wrapper around requests for easy customization
  • Small, focused surface for account and package management

Requirements

  • Python 3.8+
  • requests

Installation

pip install directadmin-cli

Quick start

from directadmin.client import DirectAdminAPIClient

client = DirectAdminAPIClient(
    server="https://your-directadmin-server.com",
    username="your-username",
    password="your-password",
    ssl=True,
    user_agent="YourCustomUserAgent/1.0"
)

Basic usage

Retrieve all users:

users = client.get_all_users()  # call the method
print("Users:", users)

Create a new user:

resp = client.create_user_account(
    username="newuser",
    email="newuser@example.com",
    passwd="securepassword",
    notify="no",
    ip="shared",           # one of: "shared", "sharedreseller", "assign"
    package="default",
    domain="newuserdomain.com"
)
print("Create user response:", resp)

Methods (summary)

  • get_all_resellers() -> List[Dict]: List all resellers.
  • get_all_admins() -> List[Dict]: List all admins.
  • get_all_users() -> List[Dict]: List all users.
  • get_all_reseller_packages() -> List[Dict]
  • get_all_user_packages() -> List[Dict]
  • get_reseller_ip_list() -> List[str]
  • get_admin_stats() -> Dict
  • suspend_account(username: str) -> Dict
  • activate_account(username: str) -> Dict

Utility methods:

  • get_reseller_package(package_name: str) -> Dict
  • get_user_package(package_name: str) -> Dict
  • get_user_config(username: str) -> Dict
  • get_user_usage(username: str) -> Dict
  • get_user_domain(username: str) -> Dict
  • create_admin_account(username: str, email: str, passwd: str, notify: str) -> Dict
  • create_reseller_account(username: str, email: str, passwd: str, notify: str, ip: str, package: str, domain: str) -> Dict
  • create_user_account(username: str, email: str, passwd: str, notify: str, ip: str, package: str, domain: str) -> Dict

Return types are approximations — check responses for the exact structure. Methods raise exceptions on network or HTTP errors (requests exceptions or custom client exceptions).

Notes & best practices

  • Use HTTPS (ssl=True) and a dedicated API account.
  • Validate package and ip values before calling create_* methods.
  • Wrap calls in try/except to handle network/HTTP errors.

Contributing

Contributions welcome. Fork the repo, create a branch, add tests and submit a pull request.

License

Apache License (see LICENSE file).

Contact

For questions or support: miladkhoshdel@gmail.com

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

directadmin_cli-0.1.7.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

directadmin_cli-0.1.7-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file directadmin_cli-0.1.7.tar.gz.

File metadata

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

File hashes

Hashes for directadmin_cli-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c500a22bcc8a01332a656aef06aa5baabcc79731ac2f2e9e1602bfbb817d20b0
MD5 92eb9b97e135dae0c1dc36ffa2171dd6
BLAKE2b-256 ece2727eace8aeacd3d57e1247fab1cbc0226afe32d88beccd477d9722043400

See more details on using hashes here.

File details

Details for the file directadmin_cli-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for directadmin_cli-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f7e1883c8992ba8296993f09424ba9f5ae6eaab9b7e47d39a2197137b384a347
MD5 97f558b82af4994120308a27bd0b20b4
BLAKE2b-256 01a6ff0a042e569e1258b05cc7cdabfd9847d93d0e6289755c39fc3e436cd271

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