MarvinKlein1508.BookStackApi 1.1.0

dotnet add package MarvinKlein1508.BookStackApi --version 1.1.0                
NuGet\Install-Package MarvinKlein1508.BookStackApi -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarvinKlein1508.BookStackApi" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MarvinKlein1508.BookStackApi --version 1.1.0                
#r "nuget: MarvinKlein1508.BookStackApi, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MarvinKlein1508.BookStackApi as a Cake Addin
#addin nuget:?package=MarvinKlein1508.BookStackApi&version=1.1.0

// Install MarvinKlein1508.BookStackApi as a Cake Tool
#tool nuget:?package=MarvinKlein1508.BookStackApi&version=1.1.0                

BookStackApi

A C# library for the BookStack API that supports async getting of books, pages & chapters. Designed to be used with Dependency Injection.

Installing

You can install from Nuget using the following command:

Install-Package MarvinKlein1508.BookStackApi

Or via the Visual Studio package manger.

Basic Usage

First you'll need to register a service. To do this we provide two extension methods. Those can be found within the namespace

using BookStackApi;

Once you have imported the namespace, you'll need to register the service with DI. You can either manually define the options

    builder.Services.AddBookstack(options => {
        options.BaseUrl = "https://yourdomain/api/";
        options.Token = "YOUR TOKEN";
        options.Secret = "YOUR SECRET";
    })

Or use the appsettings.json file to provide the configuration. Your appsettings.json needs to this section:

    "BookStack": {
        "BaseUrl": "https://yourdomain/api/",
        "Token": "YOUR TOKEN",
        "Secret": "YOUR SECRET"
    }

Please note to specify the base URL with an ending /api/. Otherwise the API does not work.

Now you can use the extensionmethod to register the service:

    builder.Services.AddBookstack(builder.Configuration));

Finally you can inject BookStackService wherever you'll need it.

Get Data

You can get data from the API by using the GetAsync<T> function. The Service will determine the correct endpoint by the specified class.

    bookStackService.GetAsync<Book>(id_of_book);
    bookStackService.GetAsync<Page>(id_of_page);
    bookStackService.GetAsync<Chapter>(id_of_chapter);

There is also a function to get a list of those objects.

    bookStackService.GetListAsync<Book>();
    bookStackService.GetListAsync<Page>();
    bookStackService.GetListAsync<Chapter>();

How do I create, update, delete, export with this API?

This features are currently not supported by this implemention. I've only implemented the features that I'll needed right now. I'll might add more features in the future once I'll need those. Otherwise feel free to create a pull request.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 140 3/11/2024
1.0.0 215 11/28/2022