# Porkbun Integration via LowCodeAPI

## Overview

Porkbun is an affordable domain registrar offering domain registration, management, and DNS services. The Porkbun API provides comprehensive functionality for:

- **Domain Registration** - Register and renew domains
- **Domain Management** - Update domain contact information and nameservers
- **DNS Management** - Create and manage DNS records
- **SSL Certificates** - Obtain and manage SSL certificates
- **Domain Availability** - Check domain availability and pricing

## Base Endpoint

```
https://api.lowcodeapi.com/porkbun/
```

## Authentication

LowCodeAPI handles authentication automatically using API Key authentication. You only need to:

1. **Sign up** at [Porkbun](https://porkbun.com) to get your API Key and Secret API Key
2. **Connect your account** in the LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Porkbun API key and Secret key
- Apply them to each request

**Auth Type**: API Key (Dual: apikey + secretapikey)

## API Categories

- **Domain & Hosting** - Domain registration and management

## Common Endpoints

### Category: Domain Availability and Pricing

#### Ping

**Method**: `POST` | **LowCodeAPI Path**: `/ping`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/ping?api_token={api_token}
```

**Description**: Test connectivity to the Porkbun API.

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/ping?api_token=YOUR_API_TOKEN"
```

**Example Response**:
```json
{
  "data": {
    "status": "OK",
    "yourIp": "192.168.1.1"
  }
}
```

**Official Documentation**: [Ping](https://porkbun.com/api/json/v3/documentation#Ping)

---

#### Domain Availability

**Method**: `POST` | **LowCodeAPI Path**: `/domain/availability`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/availability?api_token={api_token}
```

**Description**: Check if a domain is available for registration.

**Request Body**:
```json
{
  "domains": ["example.com", "example.net"]
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `domains` | array | Yes | Array of domains to check |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/availability?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "domains": ["example.com", "test.org", "mydomain.net"]
  }'
```

**Official Documentation**: [Domain Availability](https://porkbun.com/api/json/v3/documentation#Domain%20Availability)

---

#### Domain Price

**Method**: `POST` | **LowCodeAPI Path**: `/domain/price/available`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/price/available?api_token={api_token}
```

**Description**: Get pricing for available domains.

**Request Body**:
```json
{
  "domains": ["example.com", "example.net"]
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `domains` | array | Yes | Array of domains to price |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/price/available?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "domains": ["example.com", "example.net"]
  }'
```

**Official Documentation**: [Domain Price](https://porkbun.com/api/json/v3/documentation#Domain%20Price)

---

### Category: Domain Registration and Renewal

#### Register Domain

**Method**: `POST` | **LowCodeAPI Path**: `/domain/register/create`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/register/create?api_token={api_token}
```

**Description**: Register a new domain.

**Request Body**:
```json
{
  "domain": "example.com",
  "contacts": {
    "registrant": {
      "name": "John Doe",
      "email": "[email protected]",
      "phone": "+1.5555555555",
      "address": {
        "address1": "123 Main St",
        "city": "Springfield",
        "state": "IL",
        "zip": "62701",
        "country": "US"
      }
    }
  },
  "nameservers": [
    "ns1.porkbun.com",
    "ns2.porkbun.com"
  ],
  "duration": 1
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `domain` | string | Yes | Domain to register |
| `contacts` | object | Yes | Contact information object |
| `nameservers` | array | No | Nameservers for domain |
| `duration` | integer | No | Registration duration in years |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/register/create?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "mynewdomain.com",
    "contacts": {
      "registrant": {
        "name": "Jane Smith",
        "email": "[email protected]",
        "phone": "+1.5555555555",
        "address": {
          "address1": "456 Oak Ave",
          "city": "Portland",
          "state": "OR",
          "zip": "97201",
          "country": "US"
        }
      }
    },
    "duration": 1
  }'
```

**Official Documentation**: [Register Domain](https://porkbun.com/api/json/v3/documentation#Register%20Domain)

---

#### Renew Domain

**Method**: `POST` | **LowCodeAPI Path**: `/domain/renew/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/renew/domain?domain={domain}&api_token={api_token}
```

**Description**: Renew a domain registration.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to renew |

**Request Body**:
```json
{
  "duration": 1
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `duration` | integer | No | Renewal duration in years |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/renew/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"duration": 1}'
```

**Official Documentation**: [Renew Domain](https://porkbun.com/api/json/v3/documentation#Renew%20Domain)

---

### Category: Domain Management

#### Get Domain Info

**Method**: `POST` | **LowCodeAPI Path**: `/domain/getInfo/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/getInfo/domain?domain={domain}&api_token={api_token}
```

**Description**: Get information about a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to query |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/getInfo/domain?domain=example.com&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Get Domain Info](https://porkbun.com/api/json/v3/documentation#Get%20Domain%20Info)

---

#### Update Nameservers

**Method**: `POST` | **LowCodeAPI Path**: `/domain/updateNameservers/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/updateNameservers/domain?domain={domain}&api_token={api_token}
```

**Description**: Update nameservers for a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to update |

**Request Body**:
```json
{
  "ns1": "ns1.example.com",
  "ns2": "ns2.example.com",
  "ns3": "ns3.example.com"
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `ns1` | string | No | Primary nameserver |
| `ns2` | string | No | Secondary nameserver |
| `ns3` | string | No | Tertiary nameserver |
| `ns4` | string | No | Quaternary nameserver |
| `ns5` | string | No | Quinary nameserver |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/updateNameservers/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ns1": "ns1.custom-dns.com",
    "ns2": "ns2.custom-dns.com"
  }'
```

**Official Documentation**: [Update Nameservers](https://porkbun.com/api/json/v3/documentation#Update%20Nameservers)

---

#### Update Contact Information

**Method**: `POST` | **LowCodeAPI Path**: `/domain/updateContacts/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/updateContacts/domain?domain={domain}&api_token={api_token}
```

**Description**: Update contact information for a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to update |

**Request Body**:
```json
{
  "contact": "registrant",
  "name": "Jane Doe",
  "email": "[email protected]",
  "phone": "+1.5555555555",
  "address": {
    "address1": "789 New St",
    "city": "Seattle",
    "state": "WA",
    "zip": "98101",
    "country": "US"
  }
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `contact` | string | Yes | Contact type: registrant, admin, tech, billing |
| `name` | string | Yes | Contact name |
| `email` | string | Yes | Contact email |
| `phone` | string | No | Contact phone |
| "address" | object | No | Contact address object |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/updateContacts/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "contact": "registrant",
    "name": "Jane Smith",
    "email": "[email protected]",
    "phone": "+1.5555555555",
    "address": {
      "address1": "123 New Address",
      "city": "New York",
      "state": "NY",
      "zip": "10001",
      "country": "US"
    }
  }'
```

**Official Documentation**: [Update Contacts](https://porkbun.com/api/json/v3/documentation#Update%20Contact%20Information)

---

#### Lock/Unlock Domain

**Method**: `POST` | **LowCodeAPI Path**: `/domain/updateLock/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/updateLock/domain?domain={domain}&api_token={api_token}
```

**Description**: Lock or unlock a domain for transfers.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to update |

**Request Body**:
```json
{
  "lock": true
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `lock` | boolean | Yes | Lock (true) or unlock (false) domain |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/updateLock/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"lock": true}'
```

**Official Documentation**: [Lock/Unlock Domain](https://porkbun.com/api/json/v3/documentation#LockUnlock%20Domain)

---

#### Privacy Status

**Method**: `POST` | **LowCodeAPI Path**: `/domain/updatePrivacy/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/updatePrivacy/domain?domain={domain}&api_token={api_token}
```

**Description**: Enable or disable WHOIS privacy for a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to update |

**Request Body**:
```json
{
  "privacy": true
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `privacy` | boolean | Yes | Enable (true) or disable (false) privacy |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/updatePrivacy/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"privacy": true}'
```

**Official Documentation**: [Privacy Status](https://porkbun.com/api/json/v3/documentation#Privacy%20Status)

---

### Category: DNS Management

#### Retrieve DNS Records

**Method**: `POST` | **LowCodeAPI Path**: `/domain/dns/retrieve/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/dns/retrieve/domain?domain={domain}&api_token={api_token}
```

**Description**: Get DNS records for a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to query |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/retrieve/domain?domain=example.com&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Get DNS Records](https://porkbun.com/api/json/v3/documentation#Retrieve%20DNS%20Records)

---

#### Create DNS Record

**Method**: `POST` | **LowCodeAPI Path**: `/domain/dns/create/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/dns/create/domain?domain={domain}&api_token={api_token}
```

**Description**: Create a new DNS record.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to add record to |

**Request Body**:
```json
{
  "type": "A",
  "host": "www",
  "value": "192.168.1.1",
  "ttl": 300
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `type` | string | Yes | Record type: A, AAAA, CNAME, MX, TXT, NS, SRV, ALIAS |
| `host` | string | Yes | Subdomain or @ for root |
| `value` | string | Yes | Record value |
| `ttl` | integer | No | Time to live in seconds (default: 300) |
| `priority` | integer | No | Priority for MX/SRV records |
| `weight` | integer | No | Weight for SRV records |
| `port` | integer | No | Port for SRV records |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/create/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "A",
    "host": "www",
    "value": "192.168.1.100",
    "ttl": 300
  }'
```

**Official Documentation**: [Create DNS Record](https://porkbun.com/api/json/v3/documentation#Create%20DNS%20Record)

---

#### Edit DNS Record

**Method**: `POST` | **LowCodeAPI Path**: `/domain/dns/edit/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/dns/edit/domain?domain={domain}&api_token={api_token}
```

**Description**: Edit an existing DNS record.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain of the record |

**Request Body**:
```json
{
  "id": 12345,
  "type": "A",
  "host": "www",
  "value": "192.168.1.200",
  "ttl": 600
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `id` | integer | Yes | Record ID to edit |
| `type` | string | Yes | Record type |
| `host` | string | Yes | Subdomain or @ for root |
| `value` | string | Yes | New record value |
| `ttl` | integer | No | Time to live in seconds |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/edit/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": 12345,
    "type": "A",
    "host": "www",
    "value": "192.168.1.200",
    "ttl": 600
  }'
```

**Official Documentation**: [Edit DNS Record](https://porkbun.com/api/json/v3/documentation#Edit%20DNS%20Record)

---

#### Delete DNS Record

**Method**: `POST` | **LowCodeAPI Path**: `/domain/dns/delete/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/dns/delete/domain?domain={domain}&api_token={api_token}
```

**Description**: Delete a DNS record.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain of the record |

**Request Body**:
```json
{
  "id": 12345
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `id` | integer | Yes | Record ID to delete |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/delete/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"id": 12345}'
```

**Official Documentation**: [Delete DNS Record](https://porkbun.com/api/json/v3/documentation#Delete%20DNS%20Record)

---

### Category: SSL Certificates

#### Retrieve SSL Certificate

**Method**: `POST` | **LowCodeAPI Path**: `/domain/ssl/retrieve/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/ssl/retrieve/domain?domain={domain}&api_token={api_token}
```

**Description**: Retrieve SSL certificate bundle for a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to retrieve certificate for |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/ssl/retrieve/domain?domain=example.com&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [Retrieve SSL](https://porkbun.com/api/json/v3/documentation#Retrieve%20SSL%20Certificate)

---

#### Add SSL

**Method**: `POST` | **LowCodeAPI Path**: `/domain/ssl/create/domain`

**Full URL**:
```
https://api.lowcodeapi.com/porkbun/domain/ssl/create/domain?domain={domain}&api_token={api_token}
```

**Description**: Add a free Let's Encrypt SSL certificate to a domain.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `domain` | string | Yes | Domain to add SSL to |

**Request Body**:
```json
{
  "runInBackground": true
}
```

**Request Body Fields**:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `runInBackground` | boolean | No | Run certificate generation in background |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/ssl/create/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"runInBackground": true}'
```

**Official Documentation**: [Add SSL](https://porkbun.com/api/json/v3/documentation#Add%20SSL)

---

## Usage Examples

### Example 1: Check and Register a Domain

Check availability and register a new domain:

```bash
# Step 1: Check domain availability
# No ID needed - checks availability
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/availability?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domains": ["mynewdomain.com", "mynewdomain.net"]}'

# Step 2: Register the available domain
# No ID needed - registers new domain
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/register/create?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "mynewdomain.com",
    "contacts": {
      "registrant": {
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "+1.5555555555",
        "address": {
          "address1": "123 Main St",
          "city": "Springfield",
          "state": "IL",
          "zip": "62701",
          "country": "US"
        }
      }
    },
    "duration": 1
  }'
```

### Example 2: Manage DNS Records

Configure DNS for a domain:

```bash
# Step 1: Add an A record for www subdomain
# No ID needed - creates new DNS record
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/create/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "A",
    "host": "www",
    "value": "192.168.1.100",
    "ttl": 300
  }'

# Step 2: Add MX record for email
# No ID needed - creates new MX record
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/dns/create/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "MX",
    "host": "@",
    "value": "mail.example.com",
    "priority": 10,
    "ttl": 300
  }'
```

### Example 3: Obtain SSL Certificate

Add free SSL certificate to a domain:

```bash
# Step 1: Add SSL certificate
# No ID needed - adds free Let's Encrypt SSL
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/ssl/create/domain?domain=example.com&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"runInBackground": true}'

# Step 2: Retrieve SSL certificate bundle
# No ID needed - retrieves certificate for domain
curl -X POST "https://api.lowcodeapi.com/porkbun/domain/ssl/retrieve/domain?domain=example.com&api_token=YOUR_API_TOKEN"
```

## Complete Endpoint Reference

For a complete list of all 40 endpoints and their parameters, refer to:

- **OpenAPI Definition**: https://backend.lowcodeapi.com/porkbun/definition
- **Official Porkbun Documentation**: https://porkbun.com/api/json/v3/documentation

## Rate Limits & Best Practices

- **Rate Limit**: Refer to your Porkbun account
- **Best Practices**:
  - Always check domain availability before attempting registration
  - Use appropriate TTL values for DNS records (300-3600 seconds)
  - Enable WHOIS privacy for personal domains
  - Lock domains to prevent unauthorized transfers
  - Store DNS record IDs for future updates/deletions
  - Use background processing for SSL certificate generation
  - Keep contact information up to date

## Error Handling

All responses are wrapped in a `data` key:
```json
{
  "data": {
    // Actual response from Porkbun
  }
}
```

Common error responses:
- **400**: Invalid parameters or request format
- **401**: Invalid API credentials
- **404**: Domain not found
- **409**: Domain unavailable or conflict
- **500**: Porkbun server error