Skip to content

ahcomputing/porkbun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

porkbun

A bash CLI for the Porkbun API v3. Manage domains, DNS records, SSL certificates, URL forwarding, and more from your terminal.

Requirements

  • bash
  • curl
  • python3

Installation

curl -o ~/.local/bin/porkbun https://raw.githubusercontent.com/ahcomputing/porkbun/main/porkbun
chmod +x ~/.local/bin/porkbun

Or clone and symlink:

git clone https://github.com/ahcomputing/porkbun.git
ln -s "$PWD/porkbun/porkbun" ~/.local/bin/porkbun

Make sure ~/.local/bin is on your PATH (add export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc or ~/.zshrc if needed).

Setup

1. Enable API access in Porkbun

Log in to Porkbun → AccountAPI 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:

Porkbun API settings showing the Opt In All Domains toggle

Without this, you'll need to opt each domain into API access individually from its domain detail page.

2. Create a credentials file

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/credentials

The file is sourced at runtime — keep it private and never commit it.


Usage

Account

porkbun ping                   # Verify credentials + show your public IP
porkbun balance                # Show account credit balance

Domains

porkbun 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 TLD

DNS

porkbun 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.

SSL

porkbun ssl example.com              # Download cert bundle to ~/ssl/example.com/
porkbun ssl example.com /etc/ssl/my  # Download to a custom directory

Writes four files (certificate.crt, private.key, public.key, intermediate.crt), all chmod 600. Only works for domains using Porkbun nameservers.

URL Forwarding

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).

DNSSEC

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

Notes

  • Changes to DNS records may take a few minutes to propagate. Use dig example.com A to verify.
  • The balance and transfer commands use GET endpoints and pass credentials as query parameters — this is required by the Porkbun API for those specific endpoints.
  • porkbun del deletes all records matching the given name and type. Use porkbun list to review first.

About

A bash CLI for the Porkbun API — manage domains, DNS records, SSL certs, URL forwarding, and more from your terminal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages