{"id":23282190,"url":"https://github.com/alilotfi23/whm-api","last_synced_at":"2026-05-09T15:07:06.972Z","repository":{"id":250462836,"uuid":"834536796","full_name":"alilotfi23/whm-api","owner":"alilotfi23","description":"Flask application that interacts with the WHM API to manage accounts, DNS records, backups, and other functionalities on a WHM server","archived":false,"fork":false,"pushed_at":"2024-08-18T17:30:27.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T20:18:08.112Z","etag":null,"topics":["api","cpanel","flask","postman","postman-collection","python3","whm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alilotfi23.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-27T15:11:19.000Z","updated_at":"2024-08-18T17:30:30.000Z","dependencies_parsed_at":"2024-08-18T18:55:12.176Z","dependency_job_id":null,"html_url":"https://github.com/alilotfi23/whm-api","commit_stats":null,"previous_names":["alilotfi23/whm-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alilotfi23%2Fwhm-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alilotfi23%2Fwhm-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alilotfi23%2Fwhm-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alilotfi23%2Fwhm-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alilotfi23","download_url":"https://codeload.github.com/alilotfi23/whm-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492543,"owners_count":20947545,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cpanel","flask","postman","postman-collection","python3","whm"],"created_at":"2024-12-20T00:14:56.023Z","updated_at":"2026-05-09T15:07:06.916Z","avatar_url":"https://github.com/alilotfi23.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask WHM API Application\n\nThis is a Flask application that interacts with the WHM API to manage accounts, DNS records, backups, and other functionalities on a WHM server.\n\n## Features\n\n- List accounts\n- Create an account\n- Suspend an account\n- Modify an account\n- Change account plan/package\n- Change account password\n- Delete an account\n- Unsuspend an account\n- List users\n- Add, remove, and edit DNS zone records\n- Configure backups\n- Add a backup destination\n- Get backup configuration\n- Add a restore task to the queue\n\n## Installation\n\n### Prerequisites\n\n- Python 3.6 or higher\n- pip (Python package installer)\n\n### Steps\n\n1. **Clone the repository:**\n\n   ```sh\n   git clone https://github.com/alilotfi23/whm-api.git\n   cd whm-api\n\n2. **Create a virtual environment (optional but recommended):**\n\n   ```sh\n   python -m venv venv\n   source venv/bin/activate  # On Windows, use `venv\\Scripts\\activate`\n   ```\n\n3. **Install the dependencies:**\n\n   ```sh\n   pip install -r requirements.txt\n   ```\n\n4. **Create a `.env` file in the root directory of your project and add your WHM server URL and token:**\n\n   ```env\n   URL=https://server_ip:whm_port# Defualt is 2087\n   TOKEN=your_token_here\n   ```\n\n5. **Run the application:**\n\n   ```sh\n   python app.py\n   ```\n\n## Docker container\n### Instructions to Build and Run the Docker Container\n\n1. **Ensure you have Docker installed:**\n   - [Docker installation instructions](https://docs.docker.com/get-docker/)\n\n2. **Build the Docker image:**\n   - Navigate to the directory containing your `Dockerfile` and the application code.\n   - Run the following command to build the Docker image:\n     ```sh\n     docker build -t flask-whm-api .\n     ```\n\n3. **Run the Docker container:**\n   - Use the following command to run the container:\n     ```sh\n     docker run -d -p 80:8080 --name flask-whm-api-container flask-whm-api\n     ```\n\n4. **Access the application:**\n   - Open your web browser and navigate to `http://localhost:8080` to access your Flask application.\n\n\n## Endpoints\n\n### List Accounts\n\n- **URL:** `/listaccts`\n- **Method:** `GET`\n- **Response:**\n  ```json\n  [\n    {\n      \"user\": \"example_user\",\n      \"domain\": \"example.com\",\n      \"plan\": \"basic\",\n      \"email\": \"user@example.com\",\n      \"backup\": \"enabled\",\n      \"suspended\": \"no\"\n    }\n  ]\n  ```\n\n### Create an Account\n\n- **URL:** `/createacct`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"domain\": \"example.com\",\n    \"username\": \"example_user\",\n    \"password\": \"password123\",\n    \"contactemail\": \"user@example.com\",\n    \"plan\": \"basic\",\n    \"dkim\": \"enabled\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account created successfully.\"\n  }\n  ```\n\n### Suspend an Account\n\n- **URL:** `/suspend`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account suspended successfully.\"\n  }\n  ```\n\n### Modify an Account\n\n- **URL:** `/modify`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\",\n    \"domain\": \"example.com\",\n    \"contactemail\": \"new_email@example.com\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account modified successfully.\"\n  }\n  ```\n\n### Change Account Plan/Package\n\n- **URL:** `/changeplan`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\",\n    \"pkg\": \"premium\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account package changed successfully.\"\n  }\n  ```\n\n### Change Account Password\n\n- **URL:** `/changepass`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\",\n    \"password\": \"new_password123\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account password changed successfully.\"\n  }\n  ```\n\n### Delete an Account\n\n- **URL:** `/deleteacct`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"username\": \"example_user\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account deleted successfully.\"\n  }\n  ```\n\n### Unsuspend an Account\n\n- **URL:** `/unsuspend`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Account unsuspended successfully.\"\n  }\n  ```\n\n### List Users\n\n- **URL:** `/listusers`\n- **Method:** `GET`\n- **Response:**\n  ```json\n  [\n    {\n      \"username\": \"example_user\",\n      \"email\": \"user@example.com\"\n    }\n  ]\n  ```\n\n### Add a DNS Zone Record\n\n- **URL:** `/addzonerecord`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"domain\": \"example.com\",\n    \"name\": \"www\",\n    \"dnsclass\": \"IN\",\n    \"ttl\": \"3600\",\n    \"type\": \"A\",\n    \"address\": \"192.0.2.1\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"DNS zone record added successfully.\"\n  }\n  ```\n\n### Remove a DNS Zone Record\n\n- **URL:** `/removezonerecord`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"zone\": \"example.com\",\n    \"line\": \"1\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"DNS zone record removed successfully.\"\n  }\n  ```\n\n### Edit a DNS Zone Record\n\n- **URL:** `/editzonerecord`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"domain\": \"example.com\",\n    \"line\": \"1\",\n    \"name\": \"www\",\n    \"dnsclass\": \"IN\",\n    \"ttl\": \"3600\",\n    \"type\": \"A\",\n    \"address\": \"192.0.2.2\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"DNS zone record edited successfully.\"\n  }\n  ```\n\n### Configure Backup Settings\n\n- **URL:** `/backupconfig`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"backup_daily_retention\": 7,\n    \"backup_monthly_enable\": \"yes\",\n    \"backup_monthly_dates\": [1, 15],\n    \"backup_monthly_retention\": 3,\n    \"backup_weekly_day\": \"Sunday\",\n    \"backup_weekly_enable\": \"yes\",\n    \"backup_weekly_retention\": 4,\n    \"backupdays\": [\"Monday\", \"Wednesday\", \"Friday\"],\n    \"backupenable\": \"yes\",\n    \"backuplogs\": \"yes\",\n    \"backupsuspendedaccts\": \"yes\",\n    \"backuptype\": \"full\",\n    \"maximum_restore_timeout\": 3600,\n    \"maximum_timeout\": 1800,\n    \"min_free_space\": 500,\n    \"min_free_space_unit\": \"MB\",\n    \"mysqlbackup\": \"yes\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Backup configuration set successfully.\"\n  }\n  ```\n\n### Add a Backup Destination\n\n- **URL:** `/backupdest`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"name\": \"example_backup\",\n    \"type\": \"S3\",\n    \"disabled\": \"no\",\n    \"bucket\": \"example-bucket\",\n    \"aws_access_key_id\": \"your_access_key_id\",\n    \"password\": \"your_password\",\n    \"application_key\": \"your_application_key\",\n    \"application_key_id\": \"your_application_key_id\",\n    \"bucket_id\": \"your_bucket_id\",\n    \"bucket_name\": \"example-bucket\",\n    \"script\": \"your_script\",\n    \"host\": \"example.com\",\n    \"username\": \"your_username\",\n    \"client_id\": \"your_client_id\",\n    \"client_secret\": \"your_client_secret\",\n    \"authtype\": \"your_authtype\",\n    \"path\": \"/backup/path\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Backup destination added successfully.\"\n  }\n  ```\n\n### Get Backup Configuration\n\n- **URL:** `/getbackupconfig`\n- **Method:** `GET`\n- **Response:**\n  ```json\n  {\n    \"backup_daily_retention\": 7,\n    \"backup_monthly_enable\": \"yes\",\n    \"backup_monthly_dates\": [1, 15],\n    \"backup_monthly_retention\": 3,\n    \"backup_weekly_day\": \"Sunday\",\n    \"backup_weekly_enable\": \"yes\",\n    \"backup_weekly_retention\": \"yes\",\n    \"backupdays\": [\"Monday\", \"Wednesday\", \"Friday\"],\n    \"backupenable\": \"yes\",\n    \"backuplogs\": \"yes\",\n    \"backupsuspendedaccts\": \"yes\",\n    \"backuptype\": \"full\",\n    \"maximum_restore_timeout\": 3600,\n    \"maximum_timeout\": 1800,\n    \"min_free_space\": 500,\n    \"min_free_space_unit\": \"MB\",\n    \"mysqlbackup\": \"yes\"\n  }\n  ```\n\n### Add a Restore Task to the Queue\n\n- **URL:** `/restorequeueadd`\n- **Method:** `POST`\n- **Request Body:**\n  ```json\n  {\n    \"user\": \"example_user\",\n    \"restore_point\": \"2022-01-01T00:00:00Z\"\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"result\": \"success\",\n    \"details\": \"Restore task added to queue successfully.\"\n  }\n  ```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contribution\n\nWe welcome contributions to improve this project! Here are some ways you can contribute:\n\n1. **Report Bugs:** If you find a bug, please open an issue on GitHub with detailed information on how to reproduce it.\n2. **Feature Requests:** If you have ideas for new features or improvements, feel free to open an issue or submit a pull request.\n3. **Pull Requests:** If you'd like to contribute code, fork the repository and create a new branch for your feature or bug fix. Submit a pull request with a clear description of your changes.\n\nPlease ensure your contributions adhere to our coding standards and include appropriate tests.\n\nThank you for your contributions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falilotfi23%2Fwhm-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falilotfi23%2Fwhm-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falilotfi23%2Fwhm-api/lists"}