pub struct GhostContentClient { /* private fields */ }Expand description
Read-only client for the Ghost Content API.
Communicates with /ghost/api/content/ using a ContentApiKey passed as
a query parameter. All methods are async and require a Tokio runtime.
The client sets Accept-Version: v5.0 on every request.
§Example
use ghost_io_api::auth::content::ContentApiKey;
use ghost_io_api::client::content::{GhostContentClient, BrowsePostsParams};
let key = ContentApiKey::new("22444f78447824223cefc48062")?;
let client = GhostContentClient::new("https://demo.ghost.io", key)?;
// Browse posts
let posts = client.browse_posts(BrowsePostsParams::default()).await?;
// Read by ID
let post = client.read_post_by_id("5ddc9141c35e7700383b2937", None).await?;
// Read by slug
let post = client.read_post_by_slug("welcome", None).await?;Implementations§
Source§impl GhostContentClient
impl GhostContentClient
Sourcepub fn new(base_url: impl Into<String>, api_key: ContentApiKey) -> Result<Self>
pub fn new(base_url: impl Into<String>, api_key: ContentApiKey) -> Result<Self>
Creates a new GhostContentClient.
Trailing slashes on base_url are stripped automatically.
§Errors
Returns GhostError::Http if the underlying reqwest client cannot be built.
Sourcepub async fn browse_posts(
&self,
params: BrowsePostsParams,
) -> Result<PostsResponse>
pub async fn browse_posts( &self, params: BrowsePostsParams, ) -> Result<PostsResponse>
Browses published posts with optional filtering, sorting, and pagination.
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.
Sourcepub async fn read_post_by_id(
&self,
id: &str,
include: Option<&str>,
) -> Result<Post>
pub async fn read_post_by_id( &self, id: &str, include: Option<&str>, ) -> Result<Post>
Reads a single post by its Ghost ID.
include is an optional comma-separated list of relations to embed, e.g. "authors,tags".
§Errors
Returns GhostError::Api with "NotFoundError" if no
post matches the ID, or a network / decoding error otherwise.
Sourcepub async fn read_post_by_slug(
&self,
slug: &str,
include: Option<&str>,
) -> Result<Post>
pub async fn read_post_by_slug( &self, slug: &str, include: Option<&str>, ) -> Result<Post>
Reads a single post by its slug.
include is an optional comma-separated list of relations to embed, e.g. "authors,tags".
§Errors
Returns GhostError::Api with "NotFoundError" if no
post matches the slug, or a network / decoding error otherwise.
Sourcepub async fn browse_pages(
&self,
params: BrowsePagesParams,
) -> Result<PagesResponse>
pub async fn browse_pages( &self, params: BrowsePagesParams, ) -> Result<PagesResponse>
Browses published pages with optional filtering, sorting, and pagination.
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.
Sourcepub async fn read_page_by_id(
&self,
id: &str,
include: Option<&str>,
) -> Result<Page>
pub async fn read_page_by_id( &self, id: &str, include: Option<&str>, ) -> Result<Page>
Reads a single page by its Ghost ID.
include is an optional comma-separated list of relations to embed, e.g. "authors".
§Errors
Returns GhostError::Api with "NotFoundError" if no
page matches the ID, or a network / decoding error otherwise.
Sourcepub async fn read_page_by_slug(
&self,
slug: &str,
include: Option<&str>,
) -> Result<Page>
pub async fn read_page_by_slug( &self, slug: &str, include: Option<&str>, ) -> Result<Page>
Reads a single page by its slug.
include is an optional comma-separated list of relations to embed, e.g. "authors".
§Errors
Returns GhostError::Api with "NotFoundError" if no
page matches the slug, or a network / decoding error otherwise.
Browses tags with optional filtering, sorting, and pagination.
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.
Sourcepub async fn read_tag_by_id(
&self,
id: &str,
include: Option<&str>,
) -> Result<Tag>
pub async fn read_tag_by_id( &self, id: &str, include: Option<&str>, ) -> Result<Tag>
Reads a single tag by its Ghost ID.
include accepts "count.posts" to embed the post count for this tag.
§Errors
Returns GhostError::Api with "NotFoundError" if no
tag matches the ID, or a network / decoding error otherwise.
Sourcepub async fn read_tag_by_slug(
&self,
slug: &str,
include: Option<&str>,
) -> Result<Tag>
pub async fn read_tag_by_slug( &self, slug: &str, include: Option<&str>, ) -> Result<Tag>
Reads a single tag by its slug.
include accepts "count.posts" to embed the post count for this tag.
§Errors
Returns GhostError::Api with "NotFoundError" if no
tag matches the slug, or a network / decoding error otherwise.
Browses authors with optional filtering, sorting, and pagination.
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.
Reads a single author by their Ghost ID.
include accepts "count.posts" to embed the post count for this author.
§Errors
Returns GhostError::Api with "NotFoundError" if no
author matches the ID, or a network / decoding error otherwise.
Reads a single author by their slug.
include accepts "count.posts" to embed the post count for this author.
§Errors
Returns GhostError::Api with "NotFoundError" if no
author matches the slug, or a network / decoding error otherwise.
Sourcepub async fn browse_tiers(
&self,
params: BrowseTiersParams,
) -> Result<TiersResponse>
pub async fn browse_tiers( &self, params: BrowseTiersParams, ) -> Result<TiersResponse>
Browses membership tiers (free and paid).
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.
Sourcepub async fn get_settings(&self) -> Result<Settings>
pub async fn get_settings(&self) -> Result<Settings>
Fetches site-wide settings (title, logo, navigation, social links, etc.).
§Errors
Returns GhostError on network failure, a non-2xx HTTP
response, or a JSON decoding error.