Skip to content

oborseth/Porkbun-CLI

Repository files navigation

Porkbun CLI

Python 3.8+ License: MIT Code style: black PRs Welcome

A powerful, user-friendly command-line interface for managing domains and DNS records through the Porkbun API.

✨ Features

  • 🌐 Domain Management - List, register, check availability, manage nameservers
  • πŸ“ DNS Records - Full CRUD operations for all DNS record types (A, AAAA, CNAME, MX, TXT, SRV, etc.)
  • πŸ”€ URL Forwarding - Configure HTTP redirects (301/302) with wildcard support
  • πŸ”’ SSL Certificates - Retrieve and save SSL certificate bundles
  • πŸ›‘οΈ DNSSEC - Manage DNSSEC records for enhanced security
  • πŸ”— Glue Records - Create and manage nameserver glue records
  • πŸ’° Pricing - View current pricing for all TLDs
  • 🎨 Beautiful Output - Rich terminal formatting with tables, colors, and panels
  • πŸ” Secure Configuration - API credentials stored with restricted file permissions
  • ⚑ Type Safe - Full type hints and validation with Pydantic
  • πŸš€ Easy to Use - Intuitive command structure with helpful error messages

πŸ“¦ Installation

From Source (Development)

git clone https://github.com/yourusername/porkbun-cli.git
cd porkbun-cli

# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install
pip install -e .

From PyPI (Coming Soon)

pip install porkbun-cli

πŸš€ Quick Start

1. Get API Credentials

  1. Log in to Porkbun
  2. Go to API Access
  3. Enable API access and copy your credentials

2. Configure CLI

porkbun config set
# Or: python3 -m porkbun_cli.cli config set

Enter your API key and secret when prompted. Your credentials will be securely stored in ~/.porkbun/config.json.

3. Test Connection

porkbun ping

You should see: βœ“ API connection successful!

4. Start Managing Domains

# List your domains
porkbun domain list

# Check domain availability
porkbun domain check awesome-domain.com

# List DNS records
porkbun dns list example.com

# Create a DNS record
porkbun dns create example.com --type A --name www --content 192.0.2.1 --ttl 600

# View pricing
porkbun pricing --search dev

πŸ“– Usage

Domain Management

# List all domains
porkbun domain list

# Check if domain is available
porkbun domain check example.com

# Register a domain (899 pennies = $8.99)
porkbun domain create example.com --cost 899

# Get nameservers
porkbun domain get-ns example.com

# Update nameservers
porkbun domain update-ns example.com ns1.example.com ns2.example.com

# Enable auto-renewal
porkbun domain auto-renew example.com --enable

DNS Management

# List all DNS records
porkbun dns list example.com

# Create A record
porkbun dns create example.com \
  --type A \
  --name www \
  --content 192.0.2.1 \
  --ttl 600

# Create MX record
porkbun dns create example.com \
  --type MX \
  --content mail.example.com \
  --priority 10

# Edit record
porkbun dns edit example.com RECORD_ID \
  --type A \
  --content 192.0.2.2

# Delete record
porkbun dns delete example.com RECORD_ID --yes

# List records by type
porkbun dns list-by-type example.com A www

URL Forwarding

# List forwards
porkbun forward list example.com

# Add permanent redirect (301)
porkbun forward add example.com \
  --subdomain www \
  --location https://example.com \
  --type permanent

# Add with wildcard
porkbun forward add example.com \
  --location https://example.com \
  --type permanent \
  --wildcard

# Delete forward
porkbun forward delete example.com FORWARD_ID

SSL Certificates

# View certificate
porkbun ssl get example.com

# Save to files
porkbun ssl get example.com --save --output ./certs/

Additional Commands

See full documentation:

🎨 Command Structure

porkbun
β”œβ”€β”€ ping              # Test API connectivity
β”œβ”€β”€ pricing           # View TLD pricing
β”œβ”€β”€ config            # Manage configuration
β”‚   β”œβ”€β”€ set          # Set credentials
β”‚   β”œβ”€β”€ show         # Show config (masked)
β”‚   └── path         # Show config file path
β”œβ”€β”€ domain            # Domain management
β”‚   β”œβ”€β”€ list         # List domains
β”‚   β”œβ”€β”€ check        # Check availability
β”‚   β”œβ”€β”€ create       # Register domain
β”‚   β”œβ”€β”€ get-ns       # Get nameservers
β”‚   β”œβ”€β”€ update-ns    # Update nameservers
β”‚   └── auto-renew   # Manage auto-renewal
β”œβ”€β”€ dns               # DNS records
β”‚   β”œβ”€β”€ list         # List all records
β”‚   β”œβ”€β”€ get          # Get specific record
β”‚   β”œβ”€β”€ create       # Create record
β”‚   β”œβ”€β”€ edit         # Edit record
β”‚   β”œβ”€β”€ delete       # Delete record
β”‚   β”œβ”€β”€ list-by-type # Filter by type
β”‚   └── delete-by-type
β”œβ”€β”€ forward           # URL forwarding
β”‚   β”œβ”€β”€ list
β”‚   β”œβ”€β”€ add
β”‚   └── delete
β”œβ”€β”€ ssl               # SSL certificates
β”‚   └── get
β”œβ”€β”€ glue              # Glue records
β”‚   β”œβ”€β”€ list
β”‚   β”œβ”€β”€ create
β”‚   β”œβ”€β”€ update
β”‚   └── delete
└── dnssec            # DNSSEC
    β”œβ”€β”€ list
    β”œβ”€β”€ create
    └── delete

πŸ”§ Configuration

Configuration is stored in ~/.porkbun/config.json with restricted permissions (0600).

# Set credentials interactively
porkbun config set

# Set credentials directly
porkbun config set --apikey pk_xxx --secret sk_xxx

# View configuration (credentials masked)
porkbun config show

# Show config file path
porkbun config path

πŸ› οΈ Development

Setup

# Clone repository
git clone https://github.com/yourusername/porkbun-cli.git
cd porkbun-cli

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install in development mode
pip install -e .

# Install dev dependencies
pip install -r requirements-dev.txt

Testing

# Run tests
pytest

# With coverage
pytest --cov=porkbun_cli

# Type checking
mypy porkbun_cli/

# Linting
flake8 porkbun_cli/

# Format code
black porkbun_cli/

πŸ“š Documentation

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Support

⭐ Star History

If you find this project useful, please consider giving it a star on GitHub!


Made with ❀️ for the domain management community

About

Porkbun CLI

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors