ð Domains¶
Domain management operations and types.
ð Quick Examples¶
List All Domains¶
from oinker import AsyncPiglet
async with AsyncPiglet() as piglet:
# List all domains in account
domains = await piglet.domains.list()
for domain in domains:
print(f"{domain.domain} - expires {domain.expire_date}")
# Include label information
domains = await piglet.domains.list(include_labels=True)
for domain in domains:
if domain.labels:
labels = ", ".join(label.title for label in domain.labels)
print(f"{domain.domain} [{labels}]")
Nameservers¶
async with AsyncPiglet() as piglet:
# Get current nameservers
nameservers = await piglet.domains.get_nameservers("example.com")
print(f"Current nameservers: {nameservers}")
# Update nameservers
await piglet.domains.update_nameservers("example.com", [
"ns1.example.com",
"ns2.example.com",
])
URL Forwarding¶
from oinker import URLForwardCreate
async with AsyncPiglet() as piglet:
# Get existing forwards
forwards = await piglet.domains.get_url_forwards("example.com")
for forward in forwards:
print(f"{forward.subdomain or '@'} -> {forward.location}")
# Add a new forward
await piglet.domains.add_url_forward(
"example.com",
URLForwardCreate(
subdomain="blog",
location="https://blog.example.com",
forward_type="permanent",
include_path=True,
wildcard=False,
)
)
# Delete a forward by ID
await piglet.domains.delete_url_forward("example.com", forward_id="12345")
Check Domain Availability¶
async with AsyncPiglet() as piglet:
availability = await piglet.domains.check("coolname.com")
if availability.available:
print(f"Available! Price: ${availability.pricing.registration}")
else:
print("Domain is taken")
Glue Records¶
Glue records are used when you run your own nameservers on subdomains of your domain.
async with AsyncPiglet() as piglet:
# Get existing glue records
glue_records = await piglet.domains.get_glue_records("example.com")
for record in glue_records:
print(f"{record.host}: IPv4={record.ipv4}, IPv6={record.ipv6}")
# Create a glue record for ns1.example.com
await piglet.domains.create_glue_record(
"example.com",
subdomain="ns1",
ips=["192.168.1.1", "2001:db8::1"]
)
# Update a glue record
await piglet.domains.update_glue_record(
"example.com",
subdomain="ns1",
ips=["192.168.1.2", "2001:db8::2"]
)
# Delete a glue record
await piglet.domains.delete_glue_record("example.com", subdomain="ns1")
Operations¶
AsyncDomainsAPI¶
oinker.domains.AsyncDomainsAPI
¶
Async domain operations for the Porkbun API.
Accessed via piglet.domains.* methods.
Initialize Domains API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
http
|
HttpClient
|
The HTTP client for making requests. |
required |
Source code in src/oinker/domains/_api.py
list
async
¶
List all domains in the account.
Domains are returned in chunks of 1000. Increment start by 1000 until you receive an empty list to get all domains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
int
|
Index to start from (default 0). |
0
|
include_labels
|
bool
|
Whether to include label info (default False). |
False
|
Returns:
| Type | Description |
|---|---|
list[DomainInfo]
|
List of domain info objects. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
get_nameservers
async
¶
Get the authoritative nameservers for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of nameserver hostnames. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
update_nameservers
async
¶
Update the nameservers for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
nameservers
|
list[str]
|
List of nameserver hostnames. |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
get_url_forwards
async
¶
Get URL forwarding rules for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
Returns:
| Type | Description |
|---|---|
list[URLForward]
|
List of URL forwarding rules. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
add_url_forward
async
¶
Add a URL forwarding rule for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
forward
|
URLForwardCreate
|
The URL forward configuration. |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
delete_url_forward
async
¶
Delete a URL forwarding rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
forward_id
|
str
|
The forwarding rule ID to delete. |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain or forward is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
check
async
¶
Check a domain's availability.
Note: Domain checks are rate limited.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name to check (e.g., "example.com"). |
required |
Returns:
| Type | Description |
|---|---|
DomainAvailability
|
Domain availability information including pricing. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
RateLimitError
|
If rate limit exceeded. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
get_glue_records
async
¶
Get glue records for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
Returns:
| Type | Description |
|---|---|
list[GlueRecord]
|
List of glue records. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
create_glue_record
async
¶
Create a glue record for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
subdomain
|
str
|
The glue host subdomain (e.g., "ns1"). |
required |
ips
|
list[str]
|
List of IP addresses (IPv4 and/or IPv6). |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
update_glue_record
async
¶
Update a glue record for a domain.
Replaces all existing IP addresses with the new list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
subdomain
|
str
|
The glue host subdomain (e.g., "ns1"). |
required |
ips
|
list[str]
|
List of IP addresses (IPv4 and/or IPv6). |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain or glue record is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
delete_glue_record
async
¶
Delete a glue record for a domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
The domain name (e.g., "example.com"). |
required |
subdomain
|
str
|
The glue host subdomain (e.g., "ns1"). |
required |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
NotFoundError
|
If domain or glue record is not found. |
APIError
|
If the request fails. |
Source code in src/oinker/domains/_api.py
SyncDomainsAPI¶
oinker.domains.SyncDomainsAPI
¶
Bases: SyncAPIBase['AsyncDomainsAPI']
Synchronous domain operations for the Porkbun API.
Accessed via piglet.domains.* methods.
Source code in src/oinker/_sync_base.py
list
¶
get_nameservers
¶
update_nameservers
¶
See :meth:AsyncDomainsAPI.update_nameservers.
get_url_forwards
¶
add_url_forward
¶
delete_url_forward
¶
check
¶
get_glue_records
¶
create_glue_record
¶
See :meth:AsyncDomainsAPI.create_glue_record.
update_glue_record
¶
See :meth:AsyncDomainsAPI.update_glue_record.
delete_glue_record
¶
Types¶
DomainInfo¶
oinker.DomainInfo
dataclass
¶
DomainInfo(
domain: str,
status: str,
tld: str,
create_date: datetime | None,
expire_date: datetime | None,
security_lock: bool,
whois_privacy: bool,
auto_renew: bool,
not_local: bool,
labels: tuple[DomainLabel, ...],
)
Information about a domain in the account.
Attributes:
| Name | Type | Description |
|---|---|---|
domain |
str
|
The domain name. |
status |
str
|
The domain status (e.g., "ACTIVE"). |
tld |
str
|
The top-level domain. |
create_date |
datetime | None
|
When the domain was created. |
expire_date |
datetime | None
|
When the domain expires. |
security_lock |
bool
|
Whether security lock is enabled. |
whois_privacy |
bool
|
Whether WHOIS privacy is enabled. |
auto_renew |
bool
|
Whether auto-renew is enabled. |
not_local |
bool
|
Whether the domain is not local. |
labels |
tuple[DomainLabel, ...]
|
Labels attached to the domain. |
from_api_response
classmethod
¶
Create from API response data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The API response dictionary. |
required |
Returns:
| Type | Description |
|---|---|
DomainInfo
|
A DomainInfo instance. |
Source code in src/oinker/domains/_types.py
DomainLabel¶
oinker.DomainLabel
dataclass
¶
A label attached to a domain.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The label ID. |
title |
str
|
The label title. |
color |
str
|
The label color (hex format). |
from_api_response
classmethod
¶
Create from API response data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The API response dictionary. |
required |
Returns:
| Type | Description |
|---|---|
DomainLabel
|
A DomainLabel instance. |
Source code in src/oinker/domains/_types.py
DomainAvailability¶
oinker.DomainAvailability
dataclass
¶
DomainAvailability(
available: bool,
type: str,
price: str,
regular_price: str,
first_year_promo: bool,
premium: bool,
renewal: DomainPricing | None,
transfer: DomainPricing | None,
)
Domain availability check result.
Attributes:
| Name | Type | Description |
|---|---|---|
available |
bool
|
Whether the domain is available for registration. |
type |
str
|
The operation type (registration). |
price |
str
|
The current price. |
regular_price |
str
|
The regular (non-promo) price. |
first_year_promo |
bool
|
Whether first year promo pricing applies. |
premium |
bool
|
Whether this is a premium domain. |
renewal |
DomainPricing | None
|
Renewal pricing info. |
transfer |
DomainPricing | None
|
Transfer pricing info. |
from_api_response
classmethod
¶
Create from API response data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The "response" dictionary from API. |
required |
Returns:
| Type | Description |
|---|---|
DomainAvailability
|
A DomainAvailability instance. |
Source code in src/oinker/domains/_types.py
DomainPricing¶
oinker.DomainPricing
dataclass
¶
Pricing information for a domain operation.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The operation type (registration, renewal, transfer). |
price |
str
|
The current price. |
regular_price |
str
|
The regular (non-promo) price. |
URLForward¶
oinker.URLForward
dataclass
¶
URLForward(
id: str,
subdomain: str,
location: str,
type: URLForwardType,
include_path: bool,
wildcard: bool,
)
A URL forwarding rule for a domain.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The forward rule ID. |
subdomain |
str
|
The subdomain being forwarded (empty for root). |
location |
str
|
The destination URL. |
type |
URLForwardType
|
The redirect type ("temporary" or "permanent"). |
include_path |
bool
|
Whether to include the URI path in redirection. |
wildcard |
bool
|
Whether to forward all subdomains. |
from_api_response
classmethod
¶
Create from API response data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
The API response dictionary. |
required |
Returns:
| Type | Description |
|---|---|
URLForward
|
A URLForward instance. |
Source code in src/oinker/domains/_types.py
URLForwardCreate¶
oinker.URLForwardCreate
dataclass
¶
URLForwardCreate(
location: str,
type: URLForwardType = "temporary",
subdomain: str | None = None,
include_path: bool = False,
wildcard: bool = False,
)
Parameters for creating a URL forward.
Attributes:
| Name | Type | Description |
|---|---|---|
location |
str
|
Where to forward the domain to. |
type |
URLForwardType
|
The redirect type ("temporary" or "permanent"). |
subdomain |
str | None
|
The subdomain to forward (None for root). |
include_path |
bool
|
Whether to include the URI path in redirection. |
wildcard |
bool
|
Whether to forward all subdomains. |
GlueRecord¶
oinker.GlueRecord
dataclass
¶
A glue record (name server with IP addresses).
Attributes:
| Name | Type | Description |
|---|---|---|
hostname |
str
|
The full hostname (e.g., "ns1.example.com"). |
ipv4 |
tuple[str, ...]
|
List of IPv4 addresses. |
ipv6 |
tuple[str, ...]
|
List of IPv6 addresses. |
from_api_response
classmethod
¶
Create from API response data.
The API returns glue records as a tuple of [hostname, {v4: [...], v6: [...]}].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host_data
|
tuple[str, dict[str, Any]]
|
The host data tuple from API response. |
required |
Returns:
| Type | Description |
|---|---|
GlueRecord
|
A GlueRecord instance. |