The Porkbun API allows programmatic access to Porkbun's domain management services. With this API, you can manage domains, DNS records, SSL certificates, and more directly through HTTP requests.
This document provides guidance on setting up authentication, using the API endpoints, and optionally generating client code using the provided OpenAPI specification.
To interact with the Porkbun API, you need to authenticate your requests using API keys. Authentication is performed by including your apikey and secretapikey in the JSON payload of each request.
- Log in to your Porkbun account at porkbun.com.
- Navigate to the API Management page: porkbun.com/account/api.
- Generate a new API key pair. You will receive:
- API Key (
apikey) - Secret API Key (
secretapikey)
- API Key (
Note: Keep your
secretapikeysecure. Do not share it publicly or commit it to version control systems.
You can test your API keys by sending a request to the /ping endpoint. This endpoint will confirm if your credentials are valid and return your IP address.
Endpoint: https://api.porkbun.com/api/json/v3/ping
Method: POST
Headers:
Content-Type: application/json
JSON Payload:
{
"secretapikey": "YOUR_SECRET_API_KEY",
"apikey": "YOUR_API_KEY"
}A successful response will look like:
{
"status": "SUCCESS",
"yourIp": "YOUR_IP_ADDRESS"
}If you receive a "status": "SUCCESS", your API keys are working correctly.
- API Base URL:
https://api.porkbun.com/api/json/v3 - All requests must be made over HTTPS.
- HTTP Method: All endpoints use the
POSTmethod. - Content Type:
application/json - Authentication: Include
apikeyandsecretapikeyin the JSON payload.
Retrieve default pricing information for all supported TLDs.
Endpoint: /pricing/get
Request Payload:
No additional parameters required.
Example Request:
{
"secretapikey": "YOUR_SECRET_API_KEY",
"apikey": "YOUR_API_KEY"
}Example Response:
{
"status": "SUCCESS",
"pricing": {
"com": {
"registration": "9.68",
"renewal": "9.68",
"transfer": "9.68"
},
"net": {
"registration": "10.56",
"renewal": "10.56",
"transfer": "10.56"
},
// ...
}
}Update the name servers for a specific domain.
Endpoint: /domain/updateNs/{domain}
Path Parameter:
domain: The domain name you wish to update (e.g.,example.com).
Request Payload:
Include the list of name servers in the ns array.
{
"secretapikey": "YOUR_SECRET_API_KEY",
"apikey": "YOUR_API_KEY",
"ns": [
"ns1.example.com",
"ns2.example.com"
]
}Example Response:
{
"status": "SUCCESS"
}Retrieve all editable DNS records associated with a domain.
Endpoint: /dns/retrieve/{domain}
Path Parameter:
domain: The domain name (e.g.,example.com).
Request Payload:
{
"secretapikey": "YOUR_SECRET_API_KEY",
"apikey": "YOUR_API_KEY"
}Example Response:
{
"status": "SUCCESS",
"records": [
{
"id": "123456789",
"name": "example.com",
"type": "A",
"content": "192.0.2.1",
"ttl": "600",
"prio": "0",
"notes": ""
},
{
"id": "987654321",
"name": "www.example.com",
"type": "CNAME",
"content": "example.com",
"ttl": "600",
"prio": "0",
"notes": ""
}
// ...
]
}The Porkbun API supports a variety of domain and DNS management operations, including:
- Domain Management:
- List all domains
- Add URL forwarding
- Delete URL forwarding
- DNS Management:
- Create DNS records
- Edit DNS records
- Delete DNS records
- Retrieve specific DNS records
- SSL Management:
- Retrieve SSL certificate bundle
For detailed information on each endpoint and its parameters, refer to the OpenAPI Specification or the Porkbun API Documentation.
Errors are indicated by:
- HTTP Response Codes:
- Any code other than
200 OKsignifies an error. - A
403 Forbiddenresponse may indicate additional authentication is required (e.g., two-factor authentication).
- Any code other than
- Response Body:
- The
statusfield will be"ERROR". - An additional
messagefield may provide more details.
- The
Example Error Response:
{
"status": "ERROR",
"message": "Invalid API key or secret."
}To simplify interaction with the API, you can generate client libraries in various programming languages using the provided OpenAPI specification.
-
Save the OpenAPI Specification:
Save the OpenAPI YAML content to a file, e.g.,
porkbun.yaml. -
Install OpenAPI Generator:
You can use OpenAPI Generator or Swagger Codegen.
Using OpenAPI Generator CLI:
-
Install via Homebrew (macOS):
brew install openapi-generator
-
Install via npm:
npm install @openapitools/openapi-generator-cli -g
-
-
Generate Client Code:
Replace
LANGUAGEwith your desired programming language (e.g.,python,java,ruby).openapi-generator generate -i porkbun.yaml -g LANGUAGE -o ./porkbun-api-client
Example for Python:
openapi-generator generate -i porkbun.yaml -g python -o ./porkbun-api-python
-
Use the Generated Client:
Refer to the generated client's README or documentation for usage instructions.
Note: The generated client libraries may require additional configuration for authentication headers or request formatting.
- API Documentation: Detailed API documentation is available on the Porkbun website.
- Knowledge Base: Getting started with the Porkbun DNS API
- Example Code: Sample applications demonstrating API usage are available in the knowledge base.
If you need assistance or have questions about the Porkbun API:
- Email: support@porkbun.com
- Phone: 1.855.PORKBUN (1.855.767.5286)
- Hours:
- 6 AM - 5 PM Pacific Time, Monday - Friday
- 9 AM - 5 PM Pacific Time, Saturday - Sunday
- Hours:
- Knowledge Base: Porkbun Knowledge Base
Porkbun is an ICANN-accredited domain name registrar based in the Pacific Northwest, USA. We offer a variety of services, including domain registration, web hosting, SSL certificates, and more.
Address:
Porkbun LLC
21370 SW Langer Farms Parkway, Suite 142-429
Sherwood, OR 97140, USA
Made in the USA 🇺🇸
Porkbun is a Top Level Design Company.
This README is intended to help you get started with the Porkbun API. For the most up-to-date information, always refer to the official Porkbun API documentation.