Skip to main content

porkbun-cli

Python 3.8+ PyPI License: MIT

A command-line tool for managing domains and DNS records through the Porkbun API.

$ porkbun dns list example.com

ID          Type  Name               Content         Prio  TTL
----------  ----  -----------------  --------------  ----  -----
123456789   A     example.com        203.0.113.1           600
123456790   MX    example.com        mail.example.com  10  3600
123456791   TXT   example.com        v=spf1 ...            3600

Install

pip install porkbun

# With interactive menu support
pip install porkbun[interactive]

Setup

Get your API keys from porkbun.com/account/api. You need to enable API access per-domain in your Porkbun account settings.

Then run:

porkbun configure

This prompts for your API key and secret, then saves them to ~/.config/porkbun-cli/config.json with 600 permissions.

To verify the connection works:

porkbun ping
# Success! Your IP: 203.0.113.42

Commands

Domains

# List all domains in your account
porkbun domain list

# Check availability and pricing for a domain
porkbun domain search coolname.com

# Register a domain (prompts for confirmation before charging)
porkbun domain buy coolname.com

# View nameservers
porkbun domain ns example.com

# Set custom nameservers
porkbun domain ns-set example.com ns1.host.com ns2.host.com

# Download SSL certificate bundle
porkbun domain ssl example.com --output ./certs/example
# Writes example.crt, example.key, example.ca

DNS Records

# List all records
porkbun dns list example.com

# Filter by type
porkbun dns list example.com --type TXT

# Create records
porkbun dns create example.com A 203.0.113.1 --name www
porkbun dns create example.com MX mail.example.com --prio 10
porkbun dns create example.com TXT "v=spf1 include:example.com ~all"
porkbun dns create example.com CNAME target.example.com --name blog

# Edit a record by its ID
porkbun dns edit example.com 123456789 A 203.0.113.2 --name www

# Upsert — creates the record if it doesn't exist, updates it if it does
porkbun dns upsert example.com A 203.0.113.1 --name www

# Delete by ID
porkbun dns delete example.com 123456789

Supported record types: A, AAAA, CNAME, ALIAS, MX, TXT, NS, SRV, TLSA, CAA, HTTPS, SVCB, SSHFP

URL Forwarding

# List URL forwards
porkbun url list example.com

# Set a redirect (302 by default)
porkbun url set example.com https://destination.com

# Set a permanent 301 redirect from a subdomain
porkbun url set example.com https://destination.com --subdomain blog --type 301

# Wildcard redirect with path passthrough
porkbun url set example.com https://destination.com --wildcard --path

# Delete a forward
porkbun url delete example.com 987654321

Bulk Export / Import

Good for backups or migrating DNS between domains.

# Export all DNS records to JSON
porkbun bulk export example.com -o records.json

# Export as CSV
porkbun bulk export example.com --format csv -o records.csv

# Print to stdout (pipe-friendly)
porkbun bulk export example.com

# Preview what an import would do without changing anything
porkbun bulk import records.json --dry-run

# Import to original domain (reads domain from JSON file)
porkbun bulk import records.json

# Import to a different domain
porkbun bulk import records.json --domain newdomain.com

The JSON format supports an optional action field per record: create (default), upsert, or delete.

Interactive Mode

Install with [interactive] to get a menu-driven interface instead of remembering all the flags:

porkbun interactive
# or shorthand:
porkbun i

Fetches your domain list on startup so you can pick from a menu — handy when you manage several domains.

Config File

Credentials are stored at ~/.config/porkbun-cli/config.json:

{
    "apikey": "pk1_...",
    "secretapikey": "sk1_..."
}

The file is created with 600 permissions by porkbun configure. Do not commit it.

You can also pass keys directly via environment or by instantiating PorkbunAPI programmatically — see the api.py module if you want to use the client in your own scripts.

Requirements

  • Python 3.8+
  • requests
  • tabulate
  • questionary (only for porkbun interactive, installed via pip install porkbun-cli[interactive])

License

MIT — see LICENSE.

Author

Luke Steuber · GitHub · Bluesky

Metadata

Release files for porkbun 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for porkbun 1.0.0
File Size Uploaded Provenance
porkbun-1.0.0.tar.gz 13.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for porkbun 1.0.0
File Interpreter ABI Platform
porkbun-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / porkbun-1.0.0.tar.gz

Download URL porkbun-1.0.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9da1bb00864f5a89589591ecd745c02fdf29b55e74786cb58daf8147548afea8
BLAKE2b-256 checksum
How to use checksums
298ae920bd0e2257089ef00c9cd90d4c71652af169fa21af6b3db8a089615a1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / porkbun-1.0.0-py3-none-any.whl

Download URL porkbun-1.0.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73f2c73bde10e8ef77d5c6d1bd6c6f63d2a8c467bea2166847b81c6d26661895
BLAKE2b-256 checksum
How to use checksums
72b1b9dee27f0c3528d744c929423b97e892d2bb1c5c5776518ebd870e32974e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for porkbun 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page