mangadex_api
The mangadex_api
crate provides a convenient, high-level wrapper
client for the MangaDex API,
written in Rust.
It covers all public endpoints covered by their documentation.
Documentation (Project main
branch)
Please note that as MangaDex is still in beta, this SDK will be subject to sudden breaking changes.
Table of Contents
- Requirements
- How to install
- Features
- HTTP Client
- Getting Started
- Using a custom reqwest Client
- Searching manga by title
- Downloading chapter pages
- Downloading a manga's main cover image
- Changelog
- License
- Contributing
Requirements
How to install
Add mangadex-api
to your dependencies:
[]
# ...
= "1.0.0-alpha.9"
If you are using cargo-edit
, run
Features
All features are not included by default. To enable them, add any of the following to your project's Cargo.toml
file.
-
chrono
Enable the use of the
chrono
library for fields that contain datetime objects.This cannot be used with the
time
feature. -
multi-thread
Enable the
MangaDexClient
to be thread-safe, at the cost of operations being slightly more expensive. -
time
Enable the use of the
time
library for fields that contain datetime objects.This cannot be used with the
chrono
feature. -
upload
Enable endpoints that upload files to MangaDex.
For example, to enable the time
feature, add the following to your Cargo.toml
file:
= { = "1.0.0-alpha.9", = ["time"] }
HTTP Client
The mangadex_api::MangaDexClient
is asynchronous, using
reqwest
as the HTTP client.
Getting Started
This example demonstrates how to fetch a random manga.
use MangaDexClient;
async
Using a custom reqwest Client
By default, mangadex_api::MangaDexClient
will use the default
reqwest::Client
settings.
You may provide your own reqwest::Client
to customize options such as the
request timeout.
use Client;
use MangaDexClient;
# async
Searching manga by title
use MangaDexClient;
# async
Downloading chapter pages
// Imports used for downloading the pages to a file.
// They are not used because we're just printing the raw bytes.
// use std::fs::File;
// use std::io::Write;
use Url;
use Uuid;
use MangaDexClient;
# async
Downloading a manga's main cover image
While this example could directly get the cover information by passing in the cover ID, it is not often that one would have the ID off-hand, so the most common method would be from a manga result.
If you want to get all of a manga's cover images, you will need to use the cover list endpoint
and use the manga[]
query parameter.
// Imports used for downloading the cover to a file.
// They are not used because we're just printing the raw bytes.
// use std::fs::File;
// use std::io::Write;
use Url;
use Uuid;
use RelationshipType;
use MangaDexClient;
use CDN_URL;
# async
Changelog
The changelog can be found here.
Changes are added manually to keep the changelog human-readable with summaries of the changes from each version.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Contributing
We welcome contributions from everyone. There are many ways to contribute and the CONTRIBUTING.md document explains how you can contribute and get started.