Docs

Packages

Python SDK

Installation

bash
pip install pagekit-core
# or
poetry add pagekit-core
# or
uv pip install pagekit-core

Requires: Python >= 3.10

Quick Start

python
from pagekit import Pagekit

client = Pagekit(api_key="pk_live_...")

# List posts
page = client.posts.list(status="published", limit=10)
for post in page.data:
    print(post.title)

# Get a post by slug
post = client.posts.get_by_slug("hello-world")

# Create a post
post = client.posts.create(
    title="Hello world",
    content="<p>First post</p>",
    status="published",
)

# Update a post
updated = client.posts.update("post-id", title="Updated title")

# Delete a post
client.posts.delete("post-id")

Async Support

python
from pagekit import AsyncPagekit

client = AsyncPagekit(api_key="pk_live_...")

# List posts
page = await client.posts.list(status="published")

# Get by slug
post = await client.posts.get_by_slug("hello-world")

# Create a post
post = await client.posts.create(
    title="Hello world",
    content="<p>First post</p>",
)

Configuration

python
client = Pagekit(
    api_key="pk_live_...",                          # Required
    base_url="https://api.pagekit.cc/v1",           # Optional
    timeout=30,                                      # Optional (seconds)
    headers={"X-Custom-Header": "value"},           # Optional
)

API Reference

Posts

python
# List with filters
page = client.posts.list(
    status="published",
    sort="-published_at",
    page=1,
    limit=20,
    author="author-id",
    tag="engineering",
    category="tutorials",
    search="nextjs",
)

# Get single post
client.posts.get("post-id")
client.posts.get_by_slug("my-post")

# Create / Update / Delete
client.posts.create(title="...", content="...", status="draft")
client.posts.update("post-id", title="Updated")
client.posts.delete("post-id")

Authors & Categories & Tags & Media

python
client.authors.list()
client.authors.get("author-id")
client.authors.get_by_slug("jane-doe")
client.authors.create(AuthorCreateInput(name="Jane Doe", bio="Editor"))
client.authors.update("author-id", AuthorUpdateInput(bio="Senior editor"))

client.categories.list()
client.categories.get_by_slug("engineering")

client.tags.list()

client.media.list()
client.media.create(
    url="https://example.com/image.png",
    filename="image.png",
    mime_type="image/png",
    size=1024,
)
client.media.delete("media-id")

Error Handling

python
from pagekit import PagekitError

try:
    post = client.posts.get("nonexistent-id")
except PagekitError as e:
    print(e.status)         # HTTP status code
    print(e.code)           # Error code
    print(e.is_auth_error)  # 401/403
    print(e.is_rate_limited)  # 429
    print(e.is_server_error)  # 5xx

Framework Integrations

FastAPI

python
from fastapi import FastAPI, Depends
from pagekit import AsyncPagekit

app = FastAPI()

def get_pagekit():
    return AsyncPagekit(api_key="pk_live_...")

@app.get("/posts")
async def list_posts(pagekit: AsyncPagekit = Depends(get_pagekit)):
    posts = await pagekit.posts.list(status="published")
    return posts.data

Django / Flask

Works with any Python web framework — instantiate the client in your views or use dependency injection patterns.