pub struct Ferinth { /* private fields */ }
Expand description

An instance of the API to invoke API calls on.

To initialise this container,

let modrinth = Ferinth::default();
// Use the instance to call the API
let sodium_mod = modrinth.get_project("sodium").await?;

Implementations

Get a project with ID project_id

Example:

let sodium_mod = modrinth.get_project("AANobbMI").await?;
assert_eq!(
    sodium_mod.title,
    "Sodium",
);

// You can also use the project slug
let ok_zoomer_mod = modrinth.get_project("ok-zoomer").await?;
assert_eq!(
    ok_zoomer_mod.title,
    "Ok Zoomer",
);

Get multiple projects with IDs project_ids

Example:

let mods = modrinth.get_multiple_projects(&[
    "AANobbMI",
    "P7dR8mSH",
    "gvQqBUqZ",
    "YL57xq9U",
]).await?;
assert!(mods.len() == 4);

Get the dependencies of the project with ID project_id

Example:

let fabric_api = modrinth.get_project_dependencies("fabric-api").await?;
// The Fabric API should not have any dependencies
assert!(fabric_api.projects.is_empty());

Check whether the given mod ID/slug is valid. Returns the exact mod ID.

Example:

assert!("AANobbMI".to_string() == modrinth.resolve_id_slug("sodium").await?.id);

List the categories, their icons, and applicable project types

Example:

let categories = modrinth.list_categories().await?;

List the loaders, their icons, and supported project types

Example:

let loaders = modrinth.list_loaders().await?;

List the game versions and information about them

Example:

let game_versions = modrinth.list_game_versions().await?;

List licenses and information about them

Example:

let licenses = modrinth.list_licenses().await?;

List donation platforms and information about them

Example:

let donation_platforms = modrinth.list_donation_platforms().await?;

List valid report types

Example:

let report_types = modrinth.list_report_types().await?;

List the members of team with ID team_id

Example:

let mod_menu_team = modrinth.list_team_members("VMz4FpgB").await?;
assert!(mod_menu_team.len() == 4);

List the members of team with ID team_id

Example:

let mod_menu_team = modrinth.list_project_team_members("mOgUt4GM").await?;
assert!(mod_menu_team.len() == 4);

Get user with ID user_id

Example:

let jellysquid = modrinth.get_user("TEZXhE2U").await?;
assert!(jellysquid.role == UserRole::Developer);

Get a list of projects that the user owns

Example:

let jellysquid_projects = modrinth.list_projects("TEZXhE2U").await?;
assert!(jellysquid_projects.len() == 4);

Get multiple users with IDs user_ids

Example:

let users = modrinth.get_multiple_users(&["TEZXhE2U", "7Azq6eD8"]).await?;
assert!(&users[0].username == "jellysquid3");
assert!(&users[1].username == "theRookieCoder");

Get the versions of project with ID project_id

Example:

let sodium_versions = modrinth.list_versions("AANobbMI").await?;
assert!(sodium_versions[0].project_id == "AANobbMI");

Get the versions of project with ID project_id with filters

loaders: The types of loaders to filter for game_versions: The game versions to filter for featured: Filter for featured or non-featured versions only

Example:

let sodium_forge_versions = modrinth.list_versions_filtered("AANobbMI", Some(&["forge"]), None, None).await?;
assert!(sodium_forge_versions.is_empty());

Get version with ID version_id

Example:

let sodium_version = modrinth.get_version("xuWxRZPd").await?;
assert!(sodium_version.project_id == "AANobbMI");

Get multiple versions with IDs version_ids

Example:

let versions = modrinth.get_multiple_versions(&[
    "sxWTUZpD",
    "mgPpe4NY",
]).await?;
for version in versions {
    assert!(version.project_id == "of7wIinq");
}

Get the version of a version file with hash file_hash. Only supports SHA1 hashes for now

Example:

// A mod file has the hash `795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf`, so we can get the version it belongs to
let sodium_version = modrinth.get_version_from_hash("795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf").await?;
assert!(sodium_version.project_id == "AANobbMI");

Get the versions of version files with hashes file_hashes. Only supports SHA1 hashes for now

Example:

let sodium_hash = "795d4c12bffdb1b21eed5ff87c07ce5ca3c0dcbf";
let snwylvspls_hash = "994ee99d172a5950a51ec2d08c158d270722d871";
let versions = modrinth.get_versions_from_hashes(vec![
    sodium_hash.into(),
    snwylvspls_hash.into()
]).await?;
assert!(versions[sodium_hash].project_id == "AANobbMI");
assert!(versions[snwylvspls_hash].project_id == "of7wIinq");

Get the latest version of the given file_hash based on some filters

Get the latest versions of the given file_hashes based on some filters

Instantiate the container with the provided user agent information.

program_name is required, and the version and contact are optional but recommended

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more