Projects
1. The Project Object
The Project class represents a project returned by the Modrinth API.
A project can contain metadata such as its title, description, supported Minecraft versions, loaders, download count, gallery images, links, and more.
Project project = modrinth.projects().get("sodium");val project = modrinth.projects().get("sodium")You can access project metadata directly:
String title = project.title;
String description = project.description;
long downloads = project.downloads;val title = project.title
val description = project.description
val downloads = project.downloads2. Fields
The available fields depend on whether the project was returned by a search endpoint or a detail endpoint.
Project Fields Project metadata
id
Detail
The unique Modrinth project ID returned by the detail endpoint.
projectId
Search
The unique Modrinth project ID returned by the search endpoint.
slug
The human-readable identifier of the project.
title
The display name of the project.
description
A short description of the project.
body
Detail
The full project description.
bodyUrl
Legacy field, always null according to the Modrinth API.
projectType
The type of content provided by the project.
monetizationStatus
The monetization status of the project.
author
The display name of the project author.
authorId
The unique ID of the project author.
organization
The organization that owns the project, if available.
organizationId
The unique ID of the organization that owns the project, if available.
team
The ID of the team associated with the project.
clientSide
Describes the project's client-side support.
serverSide
Describes the project's server-side support.
environment
Replaces clientSide/serverSide as the preferred way to describe where the project runs. Both are still populated, but prefer this field going forward.
categories
The categories and tags assigned to the project.
displayCategories
The subset of categories shown on the project's search card.
additionalCategories
Categories assigned to the project that aren't primary categories.
versions
The IDs of every version published under the project.
gameVersions
The Minecraft versions supported by the project.
loaders
The mod loaders and platforms supported by the project.
disclosureTypes
Search
Content disclosure categories (AI content, telemetry, advertisements, and so on) the project is tagged with, returned by the search endpoint only.
downloads
The total number of project downloads.
follows
Search
The number of project followers returned by the search endpoint.
followers
Detail
The number of project followers returned by the detail endpoint.
iconUrl
The URL of the project's icon.
rawIconUrl
Detail
The unoptimized icon, returned by the detail endpoint only.
color
The project's display color.
threadId
The ID of the moderation thread associated with the project.
issuesUrl
The URL of the project's issue tracker, if any.
sourceUrl
The URL of the project's source code repository, if any.
wikiUrl
The URL of the project's wiki page, if any.
discordUrl
The invite URL of the project's Discord server, if any.
donationUrls
The donation platforms and links listed for the project.
license
License information for the project.
gallery
The images available in the project's gallery.
published
The time at which the project was published.
updated
The time at which the project was last updated.
3. Convenience Methods
The Project class provides convenience methods for common project checks and metadata access.
Project Methods Metadata and compatibility helpers
getTags()
Returns the project's categories as tags.
getDisplayTags()
Returns the subset of tags shown on the project's search card.
getAdditionalTags()
Returns tags assigned to the project that aren't primary categories.
hasTag()
Checks whether the project contains a specific tag.
hasDisplayTag()
Checks whether the project contains a specific display tag.
hasAdditionalTag()
Checks whether the project contains a specific additional tag.
hasLoader()
Checks whether the project supports a loader.
supportsVersion()
Checks whether the project supports a Minecraft version.
supportsEnvironment()
Checks whether the project supports a specific Environment value.
hasDisclosure()
Checks whether the project is tagged with a specific DisclosureType.
getFeaturedGallery()
Returns the featured gallery image, if one exists.
getLatestVersion()
Resolves the latest matching version of the project.
Checking Compatibility
boolean supportsFabric = project.hasLoader(ModLoader.FABRIC);
boolean supportsVersion = project.supportsVersion("1.21.11");
if (supportsFabric && supportsVersion) {
// The project supports Fabric on Minecraft 1.21.11
}val supportsFabric = project.hasLoader(ModLoader.FABRIC)
val supportsVersion = project.supportsVersion("1.21.11")
if (supportsFabric && supportsVersion) {
// The project supports Fabric on Minecraft 1.21.11
}Working with Tags
boolean optimization = project.hasTag("optimization");
boolean technology = project.hasDisplayTag("technology");val optimization = project.hasTag("optimization")
val technology = project.hasDisplayTag("technology")Checking Environment and Disclosures
boolean clientOnly = project.supportsEnvironment(Environment.CLIENT_ONLY);
boolean usesTelemetry = project.hasDisclosure(DisclosureType.TELEMETRY);val clientOnly = project.supportsEnvironment(Environment.CLIENT_ONLY)
val usesTelemetry = project.hasDisclosure(DisclosureType.TELEMETRY)Getting the Featured Gallery Image
getFeaturedGallery() returns the gallery image marked as featured, or null if the project has no featured image.
GalleryImage featured = project.getFeaturedGallery();
if (featured != null) {
System.out.println(featured.url);
}val featured = project.getFeaturedGallery()
if (featured != null) {
println(featured.url)
}4. Resolving the Latest Version
A project returned by a Modrinth client is automatically attached to that client. This allows you to resolve the latest matching version directly from the project.
By Game Version and Loader
Version latest = project.getLatestVersion(
"1.21.11",
ModLoader.FABRIC
);val latest = project.getLatestVersion(
"1.21.11",
ModLoader.FABRIC
)With Version Search Options
For more control, pass a VersionSearchOptions object:
VersionSearchOptions options = VersionSearchOptions.builder()
.gameVersions("1.21.11")
.loaders("fabric")
.build();
Version latest = project.getLatestVersion(options);val options = VersionSearchOptions.builder()
.gameVersions("1.21.11")
.loaders("fabric")
.build()
val latest = project.getLatestVersion(options)