Python

Bulk-insert articles and pull statistics with requests.

List published content by category

import os, requests

r = requests.get(
    "https://your-domain.com/api/content/categories",
    headers={"X-API-Key": os.environ["CONTENT_HUB_API_KEY"]},
    timeout=10,
)
r.raise_for_status()

for category, articles in r.json()["categories"].items():
    print(category, len(articles))

Insert articles

payload = {
    "articles": [
        {
            "id": "article-123",
            "title": "Understanding Car Insurance",
            "body": "<p>Content body...</p>",
            "slug": "understanding-car-insurance",
            "status": "published",
            "category": "insurance",
            "primary_keyword": "car insurance",
        }
    ]
}

r = requests.post(
    "https://your-domain.com/api/content",
    json=payload,
    headers={"X-API-Key": os.environ["CONTENT_HUB_API_KEY"]},
    timeout=30,
)
print(r.json()["stats"]["total_inserted"])
Load the key from the environmentThe snippets read CONTENT_HUB_API_KEY from the environment — never hard-code the Admin API key in your source.