GhostSharp 1.0.9

Install-Package GhostSharp -Version 1.0.9
dotnet add package GhostSharp --version 1.0.9
<PackageReference Include="GhostSharp" Version="1.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GhostSharp --version 1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GhostSharp, 1.0.9"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install GhostSharp as a Cake Addin
#addin nuget:?package=GhostSharp&version=1.0.9

// Install GhostSharp as a Cake Tool
#tool nuget:?package=GhostSharp&version=1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

CI Build License: MIT NuGet CodeFactor Open Source Helpers Language Twitter

GhostSharp

This is a wrapper around the Ghost API v3.0, a RESTful JSON API built into the core of the Ghost blogging platform. Check out the official Ghost API docs and read about my own experience using them.

Usage

Accessing the Content API

If you need to access the Content API, all you need is the URL of your site and a Content API Key, available on the "Integrations" page. Once you have those pieces of information, you can access any "public" content.

var ghost = new GhostSharp.GhostContentAPI("https://grantwinney.com", "a6d33f1b95ff17adf0f787a70a");
var settings = ghost.GetSettings();

Console.WriteLine($"Welcome to {settings.Title}: {settings.Description}\r\n");
Console.WriteLine($"Navigation: {string.Join(", ", settings.Navigation.Select(x => x.Label))}");

Output:

Welcome to Grant Winney: We learn by doing. We've all got something to contribute.

Navigation: Home, APIs, Lambda, Rasp PI, About Me, CV

Accessing the Admin API

If you need to access the Admin API, all you need is the URL of your site and an Admin API Key, also available on the "Integrations" page. Once you have those pieces of information, you can access any "private" content.

var ghost = new GhostSharp.GhostAdminAPI("https://grantwinney.com", 
    "5cf706fd7d4a33066550627a:9e5ed2b90e40f68573b0ccaf4aef666b047fc9867ad285b2e219eed5503bae53");
var site = ghost.GetSite();

Console.WriteLine($"Welcome to <a href='{site.Url}'>{site.Title}</a>\r\n");
Console.WriteLine($"Running Ghost v{site.Version}");

Output:

Welcome to <a href='https://grantwinney.com/'>Grant Winney</a>

Running Ghost v2.23

Versioning

This wrapper is written around v3.0 of the Content and Admin APIs, currently the latest version. As they update the API, I'll create a tag for the current release, before updating to the newest one.

Running the Tests

The tests are setup to run against an actual instance of the Ghost blog, using a valid API key. There are details in the TestBase.cs class that you'll need to fill in, such as a valid API key, valid post ID, valid post slug, etc, etc.

Problems?

Open an issue, and include errors, unexpected behavior, steps to reproduce, etc. The more details, the better!

Feel free to open a PR if you figure out how to fix it.

Ideas?

Open an issue. I can't promise when new features or suggestions will get implemented, but I'll check them out.

Release Notes

  • 1.0.9 - ๐Ÿ› Noticed that pages aren't being created; other refactoring.<br>Breaking change: Eliminated Page in favor of a single Post object again, for simplicity. The split wasn't necessary as a Page is just a Post that doesn't end up in feeds. Also, a few fields in a Post don't play nicely when creating pages, but I figured out a different way to omit those.
  • 1.0.8 - ๐Ÿ› Several fields marked as updateable that aren't. (thx for the heads up @unnanego)<br>Breaking change: This led to a larger refactoring, which might break some current implementations. Properties in the Post class that cannot be changed now have private setters (instead of just an attribute on them). The Page class was completely separated from the Post class, so RestSharp could correctly deserialize objects coming from Ghost.
  • 1.0.7 - โญ Implement the Themes admin endpoint. (thx for pointing me in the right direction @naz)
  • 1.0.6 - โญ Implement API v3.
  • 1.0.4 - ๐Ÿงน Code cleanup. Added license to NuGet package.
  • 1.0.3 - โญ Implement Admin API v2 endpoints (posts, pages, images, site)<br>Breaking change: GhostAPI is now split into GhostContentAPI and GhostAdminAPI
  • 1.0.1 - ๐Ÿงน Added comments to aid in intellisense.
  • 1.0.0 - โญ Implement Content API endpoints.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.9 843 9/30/2020
1.0.8 168 9/27/2020
1.0.7 175 9/23/2020
1.0.6 211 9/22/2020
1.0.4 2,376 6/5/2019
1.0.3 284 6/4/2019
1.0.2 301 3/21/2019
1.0.1 308 2/23/2019
1.0.0 296 2/22/2019