MangaDexSharp 1.0.15
See the version list below for details.
dotnet add package MangaDexSharp --version 1.0.15
NuGet\Install-Package MangaDexSharp -Version 1.0.15
<PackageReference Include="MangaDexSharp" Version="1.0.15" />
paket add MangaDexSharp --version 1.0.15
#r "nuget: MangaDexSharp, 1.0.15"
// Install MangaDexSharp as a Cake Addin #addin nuget:?package=MangaDexSharp&version=1.0.15 // Install MangaDexSharp as a Cake Tool #tool nuget:?package=MangaDexSharp&version=1.0.15
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).
You will need to ensure that you register the CardboardBox.Http
and CardboardBox.Json
packages as well (see the example below).
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()
.AddJson()
.AddCardboardHttp();
//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>")
.AddJson()
.AddCardboardHttp();
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.Pages("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.
Note: You can see an example of how to fetch bearer tokens for the new OAuth2 flow in the
src/MangaDexSharp.OAuthLocal.Web
project.
Legacy Authentication method:
You can use the legacy login method to fetch the session token like so:
var api = MangaDex.Create();
var result = await api.User.Login("<username>", "<password>");
var token = result.Data.Session;
//You can either pass the token into authenticated routes
var me = await api.User.Me(token);
//Or you can create an authenticated api
var authedApi = MangaDex.Create(token);
var me = await authedApi.User.Me();
Note: These methods are technically deprecated on mangadex's docs, so they are marked as
[Obsolete]
and will show up as warnings.
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 | Versions 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. |
-
.NETStandard 2.1
- CardboardBox.Http (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- System.Text.Json (>= 7.0.3)
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 | 306 | 3/6/2024 |
1.1.0 | 101 | 3/4/2024 |
1.0.21 | 285 | 12/11/2023 |
1.0.20 | 296 | 10/3/2023 |
1.0.19 | 157 | 9/25/2023 |
1.0.18 | 144 | 9/24/2023 |
1.0.17 | 501 | 8/17/2023 |
1.0.16 | 170 | 8/17/2023 |
1.0.15 | 174 | 7/14/2023 |
1.0.14 | 340 | 5/14/2023 |
1.0.13 | 145 | 5/1/2023 |
1.0.12 | 170 | 4/26/2023 |
1.0.11 | 182 | 4/26/2023 |
1.0.10 | 163 | 4/26/2023 |
1.0.9 | 267 | 3/30/2023 |
1.0.8 | 220 | 3/24/2023 |
1.0.7 | 263 | 2/21/2023 |
1.0.6 | 249 | 2/15/2023 |
1.0.5 | 272 | 2/10/2023 |
1.0.4 | 254 | 2/10/2023 |
1.0.3 | 266 | 2/10/2023 |
1.0.2 | 263 | 2/10/2023 |
1.0.1 | 276 | 2/10/2023 |
1.0.0 | 260 | 2/10/2023 |