A tiny shell script for interacting with the Porkbun API.
See the docs to get an API key first.
- curl (widely available)
- getopt (widely available)
- jq
To avoid having having your credentials stored in the command history, configure a file in ~/.config/porkbun-cli/credentials with the content:
PORKBUN_API_KEY=<api-key>
PORKBUN_SECRET_API_KEY<secret-api-key>
- Directly passing in credentials (see configuration section to store credentials in a file)
./porkbun-cli.sh \
--api-key pk_1234 \
--secret-api-key sk_1234 -- \
retrieve example.com- Create a record (reference)
./porkbun-cli.sh -- \
create example.com www \
--type A \
--content 1.1.1.1- Edit record by domain and id (reference)
./porkbun-cli.sh -- \
edit example.com 1234567890 \
--type A \
--name www \
--content 1.1.1.1- Edit record by domain, subdomain, and type (reference)
./porkbun-cli.sh -- \
edit-by-name-type example.com www \
--type A \
--content 1.1.1.1- Delete record by id (reference)
./porkbun-cli.sh -- \
delete example.com 1234567890- Delete record by domain, subdomain, and type (reference)
./porkbun-cli.sh -- \
delete-by-name-type example.com www \
--type A- Retrieve records by domain (reference)
./porkbun-cli.sh -- \
retrieve example.com- Retrieve records by domain and id (reference)
./porkbun-cli.sh -- \
retrieve example.com 1234567890- Upsert record by domain
# if no records exist for this domain, subdomain, type, then create it
# if one record exists for this domain, subdomain, type, then update it
# otherwise, error unless --multiple-behavior is set (see below)
./porkbun-cli.sh -- \
upsert-by-name-type example.com www \
--type A \
--content 1.1.1.1- Uniquely upsert record by domain
# if no records exist for this domain, subdomain, type, then create it
# if one record exists for this domain, subdomain, type, then update it
# otherwise, delete all records for this domain, subdomain, type and then
# create a new record
./porkbun-cli.sh -- \
upsert-by-name-type example.com www \
--type A \
--content 1.1.1.1 \
--multiple-behavior unique- Append upsert record by domain
# if no records exist for this domain, subdomain, type, then create it
# if one record exists for this domain, subdomain, type, then update it
# otherwise, append a new record
./porkbun-cli.sh -- \
upsert-by-name-type example.com www \
--type A \
--content 1.1.1.1 \
--multiple-behavior append