GhostSharp 1.0.4

This is a C# wrapper around the Ghost RESTful Content API, documented here: https://docs.ghost.org/api/content/

Install-Package GhostSharp -Version 1.0.4
dotnet add package GhostSharp --version 1.0.4
<PackageReference Include="GhostSharp" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GhostSharp --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Travis
License: MIT
NuGet
CodeFactor
Open Source Helpers
Language
Twitter

GhostSharp

This is a wrapper around the Ghost API v2.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 v2.0 of the Content and Admin APIs, currently the latest version. If they update the APIs in the future, I'll probably 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.4 - General code cleanup. Added license to NuGet package.
  • 1.0.3 - Covers stable Admin API endpoints, currently posts, pages, images, site.
  • 1.0.2 - Beginning work to support Admin API.<br>Breaking change: GhostAPI is now split into GhostContentAPI and GhostAdminAPI
  • 1.0.1 - Added comments to aid in intellisense.
  • 1.0.0 - Covers the Content API endpoints.

Travis
License: MIT
NuGet
CodeFactor
Open Source Helpers
Language
Twitter

GhostSharp

This is a wrapper around the Ghost API v2.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 v2.0 of the Content and Admin APIs, currently the latest version. If they update the APIs in the future, I'll probably 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.4 - General code cleanup. Added license to NuGet package.
  • 1.0.3 - Covers stable Admin API endpoints, currently posts, pages, images, site.
  • 1.0.2 - Beginning work to support Admin API.<br>Breaking change: GhostAPI is now split into GhostContentAPI and GhostAdminAPI
  • 1.0.1 - Added comments to aid in intellisense.
  • 1.0.0 - Covers the Content API endpoints.

Release Notes

Wrapper for the new 2.0 version of the Ghost API, including the Content API as well as the stable endpoints of the Admin API (currently posts, pages, images, and site).

Full release notes: https://github.com/grantwinney/GhostSharp/blob/master/README.md#release-notes

Version History

Version Downloads Last updated
1.0.4 67 6/5/2019
1.0.3 68 6/4/2019
1.0.2 70 3/21/2019
1.0.1 86 2/23/2019
1.0.0 85 2/22/2019