Skip to main content

A Python wrapper for Porkbun API with extra features and shortcuts

Project description

Porkbun API

This is an API wrapper for Porkbun written in Python with few extra features/shortcuts.

Porkbun API documentation

This project is subject to breaking changes as Porkbun API may change and/or become invalid. I do not guarantee anything.

Installing

You can install this through PyPi with pip: pip install porkbun-api

Or you can grab a .whl or .tar.gz file from Github releases.

Usage

This wrapper supports everything other than operations with ID's for now.

Available functions and arguments: Please keep in mind every function requires an apikey and secretapikey arguments, but you can set APIKEY and SECRETAPIKEY variables in the code or PORKBUN_APIKEY and PORKBUN_SECRETAPIKEY environment variables with their respective values and not have to give keys as arguments at every function call.

Key precedence is environment variable > code variable > function argument. Please note at the moment you can not mix and match different ways of providing your keys

  • ping()
    • Optional: ipv4only (takes True or False and returns IPv4 only if True and IPv6 if available otherwise. Default = True).
    • Returns IP address.
  • nsupdate()
    • Requires domain (takes a string of the domain you want to work on) and nslist (a list containing nameservers).
    • Does not return anything, changes the authoritative nameservers for given domain.
  • create()
    • Requires domain, rtype (string of the record type such as A, AAAA, MX, etc), and content (string value for said request type such as the IP address).
    • Optional: subdomain (string subdomain for said domain) and ttl (integer number for time to live, default and minimum for Porkbun is 600). prio (integer priority for record types that support it)
    • Does not return anything. Creates a new DNS record with given arguments.
  • read()
  • update()
    • Requires domain, rtype, and content.
    • Optional: name ttl, and prio.
    • Does not return anything. Updates the matching record with given content
  • delete()
    • Requires domain and rtype.
    • Optional subdomain.
    • Does not return anything. Deletes the matching record.
  • ddns_update()
    • Requires domain.
    • Optional: ip (the string IP address to update the record with. If not given, uses the return of ping() as IP), subdomain, and ipv4only.
    • Does not return anything. Updates the domain or subdomain's A or AAAA record depending on the IP type given.

Examples

import porkbun_api as pb
from time import sleep # only as an example, not required.

pb.APIKEY = "pk1_..." # or the env var PORKBUN_APIKEY="pk1_..."
pb.SECRETAPIKEY = "sk1_..." # or the env var PORKBUN_SECRETAPIKEY="sk1_..."

print(pb.ping())

pb.create(domain = "m3r.one", rtype = "A", content = "23.94.123.251")

pb.delete(domain = "m3r.one", rtype = "A", subdomain = "bin", apikey = "pk1_overwrite-the-variable", secretapikey = "sk1_overwrite-the-variable")

while True:
  pb.ddns_update(domain = "m3r.one")
  sleep(86400)

Notes

It is recommended to use try - except blocks with every function because it raises a PorkbunError exception if Porkbun returns an error for whatever reason. Plus, requests library will raise exceptions itself if something goes wrong with the request.

Feel free to open issues or contact me in case you wish to see extra features added.


This project is not affiliated with Porkbun LLC.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

porkbun_api-1.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

porkbun_api-1.2.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file porkbun_api-1.2.1.tar.gz.

File metadata

  • Download URL: porkbun_api-1.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for porkbun_api-1.2.1.tar.gz
Algorithm Hash digest
SHA256 cbedd82f7451b4a89b2be7b9bd0fa632f876a9064932cb302af50f2b0ac0d3fd
MD5 48d69a6f5a39d0170b99d6f4b2040c03
BLAKE2b-256 3df2461e3719e1b9fa77de2d5599265bdfe34b9725421b476814644038db1edf

See more details on using hashes here.

File details

Details for the file porkbun_api-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: porkbun_api-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for porkbun_api-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e41929ddda29f2f9306924b4aaa812c0aa6a323da150ec31190de154a3c30c11
MD5 c3ef87620c6c2aef31bfb78938d0d3d8
BLAKE2b-256 7b22fea4c9fc2d7dbec13b91f897e4bea41559cac293948d22b3781b378bbe1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page