This Python script provides a command-line interface (CLI) for interacting with the Porkbun DNS API. It allows you to create, list, and delete DNS records for a specified domain.
- Python 3.x
- requests library
- python-dotenv library
-
Clone the repository to your user directory.
cd ~ git clone https://github.com/j4m1n-t/porky-api.git cd Porky-api
-
Install the dependencies
pip install -r requirements.txt
-
Create new
.env
file in the project directory with your Porkbun API credentials. The file should look like this:apikey = your_api_key secretkey = your_secret_key
-
Update the path to the
.env
file inporky-api.py
if necessary. By default, it is set to:dotenv_path = os.path.expanduser("~/Porky-api/.env")
To use the CLI tool, run the script with the following arguments:
--domain: The domain name to operate on (e.g., example.com)
--type: The DNS record type (e.g., A, TXT, CNAME)
--value: The DNS record value (e.g., IP address, text value)
--name: Optional subdomain name (e.g., www)
To create a DNS record, use the following command:
python porky-api.py --domain example.com --type A
--value 192.0.2.1 --name www
The script automatically lists all DNS records for the domain after creating a new record.
To delete a DNS record, you can add a method in the PorkbunAPIHelper class for handling deletion and adjust the execute method accordingly.
PorkbunAPIHelper
: Handles command-line argument parsing and calls the Porkbun API.PorkbunAPI
: Manages API requests to Porkbun for creating, listing, and deleting DNS records.main()
: Entry point of the script that initializes PorkbunAPIHelper, parses arguments, and executes the operations.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or issues, please contact Jamin Thompson at [email protected].