Skip to content

DanFiedler/Libraries.IO.SDK

Repository files navigation

Libraries.IO.SDK

Introduction

A C#/.NET API wrapper for the Libraries.IO API.

Libraries.IO.SDK currently supports all of the Libraries.IO API endpoints EXCEPT subscriptions.

Usage

Add the Libraries.IO.SDK Nuget package to your project and use ILibrariesIOClient to call the desired endpoints.

This package assumes the following:

Each ILibrariesIOClient method calls the corresponding Libraries.IO API and deserializes the JSON response into strongly typed objects. (e.g., GetProject calls the https://libraries.io/api/:platform/:name endpoint.) Each method's documentation comments include the method's associated endpoint.

Basic usage is demonstrated in the samples\Libraries.IO.SDK.Sample project and in the code block below:

    // Sample DI setup of ILibrariesIOClient
    var builder = Host.CreateApplicationBuilder(args);
    builder.Services.AddHttpClient();
    builder.Services.AddSingleton<ILibrariesIOClient, LibrariesIOClient>();
    var host = builder.Build();

    // Sample usage of ILibrariesIOClient to get list of platforms from LibrariesIO
    var client = host.Services.GetRequiredService<ILibrariesIOClient>();
    var cts = new CancellationTokenSource();
    await foreach(var platform in client.GetPlatforms(cts.Token))
    {
        Console.WriteLine($"Platform: {platform.Name}");
    }

Build and Test

Libraries.IO.SDK targets .NET 8.0 and can be built and tested using standard commands.

  • Build: dotnet build
  • Run Tests: dotnet test

Contribute

Please feel free to send pull requests and raise issues (but first do a search of open issues to see if someone has already filed a similar request).

Security

See SECURITY.

License

Libraries.IO.SDK is licensed under the MIT license.