🐷 Client¶
The main entry points for the Oinker library.
AsyncPiglet¶
The async client for the Porkbun API. Use this for async applications.
oinker.AsyncPiglet
¶
AsyncPiglet(
api_key: str | None = None,
secret_key: str | None = None,
*,
base_url: str | None = None,
timeout: float | None = None,
max_retries: int | None = None,
_http_client: AsyncClient | None = None,
)
Async client for the Porkbun API.
Use as an async context manager for proper resource cleanup:
async with AsyncPiglet() as piglet:
pong = await piglet.ping()
print(f"Your IP: {pong.your_ip}")
Credentials are loaded from environment variables by default
- PORKBUN_API_KEY
- PORKBUN_SECRET_KEY
Or pass them explicitly:
async with AsyncPiglet(api_key="pk1_...", secret_key="sk1_...") as piglet:
...
Initialize the async Porkbun client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Porkbun API key. Falls back to PORKBUN_API_KEY env var. |
None
|
secret_key
|
str | None
|
Porkbun secret key. Falls back to PORKBUN_SECRET_KEY env var. |
None
|
base_url
|
str | None
|
Override the default API base URL. |
None
|
timeout
|
float | None
|
Request timeout in seconds. |
None
|
max_retries
|
int | None
|
Maximum retry attempts for transient failures. |
None
|
_http_client
|
AsyncClient | None
|
Pre-configured httpx client (for testing). |
None
|
Source code in src/oinker/_client.py
dns
property
¶
Access DNS operations.
Returns:
| Type | Description |
|---|---|
AsyncDNSAPI
|
AsyncDNSAPI instance for DNS management. |
domains
property
¶
Access domain operations.
Returns:
| Type | Description |
|---|---|
AsyncDomainsAPI
|
AsyncDomainsAPI instance for domain management. |
dnssec
property
¶
Access DNSSEC operations.
Returns:
| Type | Description |
|---|---|
AsyncDNSSECAPI
|
AsyncDNSSECAPI instance for DNSSEC management. |
ssl
property
¶
Access SSL operations.
Returns:
| Type | Description |
|---|---|
AsyncSSLAPI
|
AsyncSSLAPI instance for SSL certificate management. |
ping
async
¶
Test API connectivity and authentication.
Returns:
| Type | Description |
|---|---|
PingResponse
|
PingResponse with your public IP address. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
APIError
|
If the request fails. |
Source code in src/oinker/_client.py
Piglet¶
The sync client, wrapping AsyncPiglet for synchronous code.
oinker.Piglet
¶
Piglet(
api_key: str | None = None,
secret_key: str | None = None,
*,
base_url: str | None = None,
timeout: float | None = None,
max_retries: int | None = None,
_http_client: AsyncClient | None = None,
)
Synchronous client for the Porkbun API.
A convenience wrapper around AsyncPiglet for non-async code.
piglet = Piglet()
pong = piglet.ping()
print(f"Your IP: {pong.your_ip}")
piglet.close()
Or use as a context manager:
with Piglet() as piglet:
pong = piglet.ping()
Credentials are loaded from environment variables by default
- PORKBUN_API_KEY
- PORKBUN_SECRET_KEY
Initialize the sync Porkbun client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
Porkbun API key. Falls back to PORKBUN_API_KEY env var. |
None
|
secret_key
|
str | None
|
Porkbun secret key. Falls back to PORKBUN_SECRET_KEY env var. |
None
|
base_url
|
str | None
|
Override the default API base URL. |
None
|
timeout
|
float | None
|
Request timeout in seconds. |
None
|
max_retries
|
int | None
|
Maximum retry attempts for transient failures. |
None
|
_http_client
|
AsyncClient | None
|
Pre-configured httpx client (for testing). |
None
|
Source code in src/oinker/_sync.py
ping
¶
Test API connectivity and authentication.
Returns:
| Type | Description |
|---|---|
PingResponse
|
PingResponse with your public IP address. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If credentials are invalid. |
APIError
|
If the request fails. |
Source code in src/oinker/_sync.py
close
¶
Close the client and release resources.
PingResponse¶
oinker.PingResponse
dataclass
¶
Response from the ping endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
your_ip |
str
|
The client's public IP address as seen by Porkbun. |