Async Python client for the Ghost Admin API
Project description
aioghost
Async Python client for the Ghost Admin API.
Installation
pip install aioghost
Quick Start
import asyncio
from aioghost import GhostAdminAPI
async def main():
async with GhostAdminAPI(
api_url="https://your-site.ghost.io",
admin_api_key="your-admin-api-key"
) as api:
# Get site info
site = await api.get_site()
print(f"Site: {site['title']}")
# Get member counts
members = await api.get_members_count()
print(f"Total members: {members['total']}")
print(f"Paid members: {members['paid']}")
# Get MRR
mrr = await api.get_mrr()
print(f"MRR: ${mrr.get('usd', 0) / 100:.2f}")
asyncio.run(main())
Features
- Fully async — Built on
aiohttpfor non-blocking I/O - Type hints — Full type annotations for IDE support
- Context manager — Automatic session cleanup with
async with - Parallel requests — Uses
asyncio.gather()for efficient batching - Proper exceptions — Typed exceptions for different error cases
API Coverage
| Endpoint | Method |
|---|---|
| Site info | get_site() |
| Posts count | get_posts_count() |
| Latest post | get_latest_post() |
| Members count | get_members_count() |
| MRR | get_mrr() |
| Newsletters | get_newsletters() |
| Latest email | get_latest_email() |
| Comments count | get_comments_count() |
| Tiers | get_tiers() |
| ActivityPub stats | get_activitypub_stats() |
| Webhooks | create_webhook(), delete_webhook() |
| Validate credentials | validate_credentials() |
Getting Your Admin API Key
- Log in to your Ghost Admin panel
- Go to Settings → Integrations
- Click Add custom integration
- Copy the Admin API Key (format:
id:secret)
Exceptions
from aioghost import (
GhostError, # Base exception
GhostAuthError, # Invalid API key
GhostConnectionError, # Network error
GhostNotFoundError, # 404 response
GhostValidationError, # Invalid request
)
Passing Your Own Session
If you want to reuse an existing aiohttp.ClientSession:
import aiohttp
from aioghost import GhostAdminAPI
async def main():
async with aiohttp.ClientSession() as session:
api = GhostAdminAPI(
api_url="https://your-site.ghost.io",
admin_api_key="your-key",
session=session,
)
site = await api.get_site()
# Session is NOT closed when api goes out of scope
Copyright & license
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license. Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our trademark policy for info on acceptable usage.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioghost-0.4.0.tar.gz.
File metadata
- Download URL: aioghost-0.4.0.tar.gz
- Upload date:
- Size: 88.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a006e7eb915d52aaa3d29ead283ffc8dc24cb154efc3a77d9863ce53f8c0cb4
|
|
| MD5 |
562b0b63b504cd95ec06321b92e252f6
|
|
| BLAKE2b-256 |
3ab29eaca01d06304aae967705b97ed998366c31d1c10ea75a440d72512184da
|
Provenance
The following attestation bundles were made for aioghost-0.4.0.tar.gz:
Publisher:
publish.yml on TryGhost/aioghost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioghost-0.4.0.tar.gz -
Subject digest:
6a006e7eb915d52aaa3d29ead283ffc8dc24cb154efc3a77d9863ce53f8c0cb4 - Sigstore transparency entry: 919405949
- Sigstore integration time:
-
Permalink:
TryGhost/aioghost@ebf46fa34e0c6e90d40f2526896038dd86cc6e5e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/TryGhost
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ebf46fa34e0c6e90d40f2526896038dd86cc6e5e -
Trigger Event:
push
-
Statement type:
File details
Details for the file aioghost-0.4.0-py3-none-any.whl.
File metadata
- Download URL: aioghost-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8293e61143b9b1a0eef42ad15ad3b7bfc35073a43bbfe6d50e082840127304a4
|
|
| MD5 |
d5fd1d47b6f79daea0471e31a4acedcc
|
|
| BLAKE2b-256 |
cb7e0fe6e84db6376f967908d15a31f1d0b4d5aff87107373f615e60c463e91b
|
Provenance
The following attestation bundles were made for aioghost-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on TryGhost/aioghost
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioghost-0.4.0-py3-none-any.whl -
Subject digest:
8293e61143b9b1a0eef42ad15ad3b7bfc35073a43bbfe6d50e082840127304a4 - Sigstore transparency entry: 919405951
- Sigstore integration time:
-
Permalink:
TryGhost/aioghost@ebf46fa34e0c6e90d40f2526896038dd86cc6e5e -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/TryGhost
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ebf46fa34e0c6e90d40f2526896038dd86cc6e5e -
Trigger Event:
push
-
Statement type: