MangaDexSharp 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package MangaDexSharp --version 1.0.2                
NuGet\Install-Package MangaDexSharp -Version 1.0.2                
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="MangaDexSharp" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MangaDexSharp --version 1.0.2                
#r "nuget: MangaDexSharp, 1.0.2"                
#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 MangaDexSharp as a Cake Addin
#addin nuget:?package=MangaDexSharp&version=1.0.2

// Install MangaDexSharp as a Cake Tool
#tool nuget:?package=MangaDexSharp&version=1.0.2                

mangadex-sharp

A C# API for Mangadex.org

Installation

You can install the nuget package with Visual Studio. It targets .net standard 2.1 to take advantage of most of the new features within C# and .net.

PM> Install-Package MangaDexSharp

Setup

You can either use it directly or via dependency injection (for use with asp.net core).

Depdency Injection:


using MangaDexSharp;

var builder = WebApplication.CreateBuilder(args);

...

//This will find the authentication token in your configuration file (appsettings.json) under: "MangaDex:Token"
builder.Services.AddMangaDex(); 
//Or, if you want to inject the token directly you can use this (You don't need both of these.):
builder.Services.AddMangaDex("<AUTH TOKEN HERE>");

var app = builder.Build();

Then you can inject the API into any of your controllers or other services:

using MangaDexSharp;
using Microsoft.AspNetCore.Mvc;

namespace SomeApplication;

[ApiController]
public class SomeController : ControllerBase
{
    private readonly IMangaDex _md;

    public SomeController(IMangaDex md)
    {
        _md = md;
    }

    [HttpGet, Route("manga/{id}")]
    public async Task<IActionResult> Get(string id)
    {
        return Ok(await _md.Manga.Get(id));
    }
}

Directly:

using MangaDexSharp;

...
//You cannot access authed routes if you use this option.
var api = MangaDex.Create();

//However, you can specify the token like so:
var api = MangaDex.Create("<AUTH TOKEN HERE>");

var manga = await api.Manga.Get("some-manga-id-here");

Usage

The API follows the docs pretty closely. With the root object for the api being the IMangaDex interface. Once you have an instance (see above), you can access any of the sub-sections within it. Here are some common use cases:

var api = MangaDex.Create();

//Fetching a manga by manga ID:
var manga = await api.Manga.Get("fc0a7b86-992e-4126-b30f-ca04811979bf");

//Searching for a manga via it's title:
var results = await api.Manga.List(new MangaFilter 
{
    Title = "The Unrivaled Mememori-kun"
});

//Get all of the chapters from a manga by manga ID:
var chapters = await api.Manga.Feed("fc0a7b86-992e-4126-b30f-ca04811979bf");

//Fetch a chapter by chapter ID:
var chapter = await api.Chapter.Get("2c98fbe9-a63f-47c2-9862-ecc9199610a2");

//Get all of the pages of a specific chapter by chapter ID:
var pages = await api.Pages.Get("2c98fbe9-a63f-47c2-9862-ecc9199610a2");

Authentication

MangaDex switched to authorization bearer tokens via an OAuth2 flow recently. In order to access any resources that require an account, you will need to get one of those tokens (you can read more here once they update the docs). Once you have a bearer token, you can either add it at an API level or for a specific request, you can also create your own token service provider.

API Level:

You have 2 primary options for using this, you can either specify it directly when you create a client or inject it via configuration.

//You can apply it directly like this:
var api = MangaDex.Create("<AUTH TOKEN HERE>");

//Or if you're using dependency injection, you can provide it here:
builder.Services.AddMangaDex("<AUTH TOKEN HERE>");

//Or you can include it in your appsettings.json (or environment variables):
builder.Services.AddMangaDex();
//And then add a "MangaDex:Token": "<AUTH TOKEN HERE>" to your environment variables.
//Note: you can change the name of the environment variable by setting doing this:
MangaDexSharp.ConfigurationCredentialsService.TokenPath = "SomeEnvironmentVariableName";

Alternatively, you can create your own ICredentialsService implementation and then add it via dependency injection:

using MangaDexSharp;

//This has access to your services if you're using Dependency Injection.
public class MyCustomCredentialsService : ICredentialsService
{
    public async Task<string> GetToken() 
    {
        return "Some-token resolved here";
    }
}
...
//Then add your service like so:
builder.Services.AddMangaDex<MyCustomCredentialsService>();

Specific Request

Any request that requires authentication within the API has a string? token = null parameter on the method. The API will default to using this parameter if it's set.

var api = MangaDex.Create();

//Follow a manga
await api.Manga.Follow("fc0a7b86-992e-4126-b30f-ca04811979bf", "<AUTH TOKEN HERE>");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1 307 3/6/2024
1.1.0 102 3/4/2024
1.0.21 286 12/11/2023
1.0.20 297 10/3/2023
1.0.19 160 9/25/2023
1.0.18 145 9/24/2023
1.0.17 515 8/17/2023
1.0.16 171 8/17/2023
1.0.15 175 7/14/2023
1.0.14 341 5/14/2023
1.0.13 146 5/1/2023
1.0.12 171 4/26/2023
1.0.11 183 4/26/2023
1.0.10 166 4/26/2023
1.0.9 268 3/30/2023
1.0.8 221 3/24/2023
1.0.7 264 2/21/2023
1.0.6 250 2/15/2023
1.0.5 273 2/10/2023
1.0.4 255 2/10/2023
1.0.3 267 2/10/2023
1.0.2 264 2/10/2023
1.0.1 277 2/10/2023
1.0.0 261 2/10/2023