Skip to main content

Python client for Ghost API v3/v4/v5/v6

Reason this release was yanked:

this should have been 0.2

Project description

EDWH Ghost Client

This Client is compatible with v3, v4, v5 and v6 of the Ghost CMS Admin and Content API's.

Installation

pip install edwh-ghost

Usage

The GhostAdmin class can be instantiated as follows:

from ghost import GhostAdmin
from dotenv import dotenv_values

config = dotenv_values(".env")

# .env can be used, but config values can also be simply hardcoded
ga = GhostAdmin(
    config["GHOST_SITE"],
    adminAPIKey=config["GHOST_ADMIN_KEY"],
    contentAPIKey=config["GHOST_CONTENT_KEY"],
    api_version="v4",  # works like a train
)
print(ga.site())

If no admin API key is available, the GhostContent class can be used, which has read-only access to public endpoints.

After creating a GhostClient instance, the different Resources can be used:

from ghost.resources import *

posts: PostResource = ga.posts

# READ
multiple = posts(limit=5)  # Ghost Result Set
# alias for
posts.get(limit=5)  # Ghost Result Set

some_post = posts.get("some_id")  # Ghost Result 

for post in posts.paginate():
    # iterate without limit
    print(post)  # Ghost Result

# UPDATE
some_post.update({...})  # response dict  
# alias:
posts.update("some_id", {...})  # response dict  
# bulk:
multiple.update({...})  # response dict 

# DELETE
some_post.delete()  # bool of success
# alias:
posts.delete("some_id")  # bool of success
# bulk:
multiple.delete()  # list of bools of success

# CREATE
# one:
posts.create(title="...", etc="...")  # response dict
# bulk:
posts.create({...}, {...})  # list of response dicts

# some resources are read only:
authors: AuthorResource = ga.authors

authors()  # Ghost Result Set

authors.delete()  # error

Available Resources:

Resource Class[^1] Ghost Path Method[^2] Related Tests Admin? Content?
Posts /posts ghost.posts(), ghost.post() test_1_posts, test_10_ghost_content, test_11_ghost_paginate
Pages /pages ghost.pages(), ghost.page() test_2_pages
Authors /authors ghost.authors(), ghost.author() test_4_authors ~[^3]
Tags /tags ghost.tags(), ghost.tag() test_3_tags
Members /members ghost.members(), ghost.member() test_9_members
Images /images ghost.images.upload() test_6_images
Themes /themes ghost.themes.upload(), ghost.themes.activate() test_7_themes
Site /site ghost.site() test_8_site_and_settings
Settings /settings ghost.settings() test_8_site_and_settings ~[^3]
Users /users ghost.user(), ghost.users() test_12_users, test_13_users_content

[^1]: these classes live in ghost.resources [^2]: where ghost is an instance of a GhostClient subclass (GhostContent or GhostAdmin) [^3]: Content APIs are also accessible through the GhostAdmin client, they are however read-only

Unavailable Resources:

Resource Name Ghost Path Admin? Content? Reason
Tiers /tiers Testing Failed
Offers /offers Testing Failed
Webhooks /webhooks TODO

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

edwh_ghost-0.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edwh_ghost-0.0.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file edwh_ghost-0.0.0.tar.gz.

File metadata

  • Download URL: edwh_ghost-0.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for edwh_ghost-0.0.0.tar.gz
Algorithm Hash digest
SHA256 482ad34ec81b3333e81a87ca6d2c4b36b2d595cfe1d604c00cd8240e01bd8d33
MD5 6b7c3adbe2580ed0d7e2fc1311302538
BLAKE2b-256 764fff2798c6dbfe111326ba95c89c593a3eef88e055b0d0ab313a2026078d6c

See more details on using hashes here.

File details

Details for the file edwh_ghost-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: edwh_ghost-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for edwh_ghost-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c374c1378ac837d99ee75010f10c81e98029b61c96966af6b3d3930891db844
MD5 63f0dee72d5e1d86359e70b3e7b31f4f
BLAKE2b-256 5ce7385056cb1806ffe9b3e0060bd7c6891b62e38bd3e750d704b5beb743c77e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page