A bash CLI for the Porkbun API v3. Manage domains, DNS records, SSL certificates, URL forwarding, and more from your terminal.
bashcurlpython3
curl -o ~/.local/bin/porkbun https://raw.githubusercontent.com/ahcomputing/porkbun/main/porkbun
chmod +x ~/.local/bin/porkbunOr clone and symlink:
git clone https://github.com/ahcomputing/porkbun.git
ln -s "$PWD/porkbun/porkbun" ~/.local/bin/porkbunMake sure ~/.local/bin is on your PATH (add export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc or ~/.zshrc if needed).
Log in to Porkbun → Account → API Access. Generate an API key and secret key.
To allow API access across all your domains at once, also enable "Opt In All Domains" in API settings:
Without this, you'll need to opt each domain into API access individually from its domain detail page.
mkdir -p ~/.config/porkbun
cat > ~/.config/porkbun/credentials <<EOF
PORKBUN_API_KEY=pk1_your_key_here
PORKBUN_SECRET_KEY=sk1_your_secret_here
EOF
chmod 600 ~/.config/porkbun/credentialsThe file is sourced at runtime — keep it private and never commit it.
porkbun ping # Verify credentials + show your public IP
porkbun balance # Show account credit balanceporkbun domains # List all domains with expiry dates (color-coded by urgency)
porkbun check example.com # Check availability and registration/renewal/transfer pricing
porkbun renew example.com # Renew for 1 year
porkbun renew example.com 2 # Renew for 2 years
porkbun autorenew example.com on
porkbun autorenew example.com off
porkbun ns example.com # View current nameservers
porkbun ns example.com ns1.porkbun.com ns2.porkbun.com # Replace nameservers
porkbun transfer # List all active inbound transfers
porkbun transfer example.com # Check transfer status for a specific domain
porkbun pricing # Show pricing for all TLDs
porkbun pricing io # Filter to a specific TLDporkbun list example.com # Show all DNS records (sorted by type)
# Quickly point @ and * A records at an IP (creates or updates):
porkbun dns example.com # Uses the default IP in the script
porkbun dns example.com 1.2.3.4
# Add any record type:
porkbun add example.com A www 1.2.3.4
porkbun add example.com AAAA www 2001:db8::1
porkbun add example.com CNAME www target.example.com
porkbun add example.com MX @ mail.example.com 600 10 # last arg is priority
porkbun add example.com TXT @ "v=spf1 include:sendgrid.net ~all"
porkbun add example.com TXT @ "google-site-verification=abc123"
# Delete all records matching a name + type:
porkbun del example.com A www
porkbun del example.com TXT @
porkbun del example.com CNAME www@ refers to the root/apex of the domain.
porkbun ssl example.com # Download cert bundle to ~/ssl/example.com/
porkbun ssl example.com /etc/ssl/my # Download to a custom directoryWrites four files (certificate.crt, private.key, public.key, intermediate.crt), all chmod 600. Only works for domains using Porkbun nameservers.
porkbun forward example.com # List all forwards (shows IDs)
porkbun forward add example.com @ https://other.com # Redirect root → other.com (temporary/302)
porkbun forward add example.com shop https://shop.com perm # Permanent (301)
porkbun forward del example.com 12345 # Delete by ID (use 'forward' to find IDs)Forward types: perm / permanent (301) or temp / temporary (302, default).
porkbun dnssec example.com # List DNSSEC records
porkbun dnssec add example.com <keyTag> <alg> <digestType> <digest>
porkbun dnssec del example.com <keyTag> # Delete by key tag- Changes to DNS records may take a few minutes to propagate. Use
dig example.com Ato verify. - The
balanceandtransfercommands use GET endpoints and pass credentials as query parameters — this is required by the Porkbun API for those specific endpoints. porkbun deldeletes all records matching the given name and type. Useporkbun listto review first.
