OnCourse.Kami
2.0.2
dotnet add package OnCourse.Kami --version 2.0.2
NuGet\Install-Package OnCourse.Kami -Version 2.0.2
<PackageReference Include="OnCourse.Kami" Version="2.0.2" />
<PackageVersion Include="OnCourse.Kami" Version="2.0.2" />
<PackageReference Include="OnCourse.Kami" />
paket add OnCourse.Kami --version 2.0.2
#r "nuget: OnCourse.Kami, 2.0.2"
#:package OnCourse.Kami@2.0.2
#addin nuget:?package=OnCourse.Kami&version=2.0.2
#tool nuget:?package=OnCourse.Kami&version=2.0.2

OnCourse.Kami
OnCourse.Kami is a .NET SDK library used to communicate with the Kami API
✔ Features
Kami API library helps to generate requests for the following services:
- Embedding
- Uploads
- Documents
- View Sessions
- Exporting
⭐ Installation
This project is a class library targeting .NET 8 and .NET 10.
To install the OnCourse.Kami NuGet package, run the following command via the dotnet CLI
dotnet add package OnCourse.Kami
Or run the following command in the Package Manager Console of Visual Studio
PM> Install-Package OnCourse.Kami
📕 General Usage
Initialization
To use Kami, import the namespace and include the .AddKami() method when initializing the host builder (typically found in the Program.cs file)
using Kami;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddKamiClient(builder.Configuration);
...
var app = builder.Build();
Fault Handling / Resilience
The client is configured with a Polly v8 resilience pipeline (via Microsoft.Extensions.Http.Resilience) that retries transient failures with exponential backoff and jitter, then caps the whole call with a timeout. Both are configured from the Kami settings section — by default, 3 retries and a 100 second timeout (see Configuration). A timeout surfaces to callers as a TaskCanceledException.
For advanced scenarios you can customize the pipeline directly by passing a configuration action as the second parameter:
using Polly;
builder.Services.AddKamiClient(builder.Configuration, pipeline =>
{
pipeline.AddConcurrencyLimiter(10);
});
Note: if you host with .NET Aspire
ServiceDefaults(or otherwise callAddStandardResilienceHandlerviaConfigureHttpClientDefaults), that global handler is also applied to the Kami client and will layer a second pipeline on top. To let this SDK own Kami's resilience, opt the client out of the global handler:builder.Services.AddHttpClient(nameof(IKamiClient)).RemoveAllResilienceHandlers();
Configuration
Additional configuration can be done in the appSettings.config file within the "Kami" section. The default settings are shown here and can be overridden if needed:
{
"Kami": {
"Token": "Token #####################",
"BaseAddress": "https://api.notablepdf.com/",
"TimeoutSeconds": 100,
"RetryCount": 3,
"ExportPollIntervalSeconds": 2,
"ExportMaxPollAttempts": 60,
"AllowedExtensions": [
"doc",
"docx",
"ppt",
"pptx",
"xls",
"xlsx",
"pdf",
"odt",
"odp",
"ods",
"txt",
"rtf",
"gdoc",
"gsheet",
"jpg",
"jpeg",
"gif",
"png",
"tif",
"tiff"
]
}
}
🚀 Example
After initializing with the UseKami() method above, the client will be registered in the DI system. You can inject the client in the constructor of any class that needs to use it.
public class TestClass
{
private readonly IKamiClient kamiClient
public TestClass(IKamiClient kamiClient)
{
this.kamiClient = kamiClient;
}
public async Task<KamiUploadResult> UploadDocument(int fileId)
{
var (bytes, mimeType, fileName) = await this.GetFile(fileId);
return await this.kamiClient.UploadFile(bytes, mimeType, fileName);
}
public async Task<KamiDeleteResult> DeleteDocument(string kamiDocumentId)
{
await this.kamiClient.DeleteFile(kamiDocumentId);
}
public async Task<KamiCreateViewSessionResult> CreateViewSession(string kamiDocumentId)
{
var (username, userId) = await this.GetUser();
// optional settings
var expiresAt = DateTime.Now.AddDays(7);
var viewerOptions = new KamiViewerOptions();
// var mobileViewerOptions = KamiViewerOptions.Mobile;
var editable = true;
return await this.kamiClient.CreateViewSession(kamiDocumentId, username, userId, expiresAt, viewerOptions, editable);
}
public async Task<KamiDocumentExportResult> ExportDocument(kamiDocumentId)
{
// export type is optional, defaults to "inline". See Kami API documentation site for more options and what they do
var exportType = "inline";
return await this.kamiClient.ExportFile(kamiDocumentId, exportType);
}
}
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ardalis.GuardClauses (>= 5.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.Http (>= 10.0.8)
- Microsoft.Extensions.Http.Resilience (>= 10.6.0)
- Microsoft.Extensions.Options (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Newtonsoft.Json (>= 13.0.4)
-
net8.0
- Ardalis.GuardClauses (>= 5.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.Http (>= 10.0.8)
- Microsoft.Extensions.Http.Resilience (>= 10.6.0)
- Microsoft.Extensions.Options (>= 10.0.8)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.8)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.