Porkbun API
This is an API wrapper for Porkbun written in Python with few extra features/shortcuts.
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.
- Optional:
- nsupdate()
- Requires
domain(takes a string of the domain you want to work on) andnslist(a list containing nameservers). - Does not return anything, changes the authoritative nameservers for given domain.
- Requires
- create()
- Requires
domain,rtype(string of the record type such as A, AAAA, MX, etc), andcontent(string value for said request type such as the IP address). - Optional:
subdomain(string subdomain for said domain) andttl(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.
- Requires
- read()
- Requires
domain,rtype. - Optional:
subdomain. - Returns a list of records.
- Requires
- update()
- Requires
domain,rtype, andcontent. - Optional:
namettl, andprio. - Does not return anything. Updates the matching record with given
content
- Requires
- delete()
- Requires
domainandrtype. - Optional
subdomain. - Does not return anything. Deletes the matching record.
- Requires
- 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, andipv4only. - Does not return anything. Updates the
domainorsubdomain's A or AAAA record depending on the IP type given.
- Requires
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.
Metadata
Release files for porkbun-api 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| porkbun_api-2.0.1.tar.gz | 5.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| porkbun_api-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / porkbun_api-2.0.1.tar.gz
| Download URL | porkbun_api-2.0.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dac9193b3f179299488b0414b4847429f2691d23431bef7412674b45fb28ef40
|
|
BLAKE2b-256 checksum How to use checksums |
d6c2dacb5dc6d49dc41ab7f27001a92337e311a5679a1913d4423dec94d7bec9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / porkbun_api-2.0.1-py3-none-any.whl
| Download URL | porkbun_api-2.0.1-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
24d3c2848fb7a91494871c9da7f367d2b5ebdb6ccc1d01013793616e335b9ac1
|
|
BLAKE2b-256 checksum How to use checksums |
7a375ed067901b4765211f54fb81ff170df1b0ff02d6c2e7d775d660de28b63c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for porkbun-api 2.0.1
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.