Skip to content

Versions

The VersionsClient provides access to Modrinth project versions, files, and dependencies.

You can fetch individual versions, retrieve versions for a project, resolve the latest compatible version, and look up versions by file hashes.

Access it through the main Modrinth client:

modrinth.versions()

Fetch a version by its ID:

Version version = modrinth.versions().get("version-id");

Fetch multiple versions at once:

List<Version> versions = modrinth.versions().getMany(
"version-id-1",
"version-id-2"
);

Use getByProject() to fetch all versions of a project:

List<Version> versions = modrinth.versions()
.getByProject("sodium");

Pass a VersionSearchOptions object to filter versions:

VersionSearchOptions options = VersionSearchOptions.builder()
.gameVersions("1.21.11")
.loaders(ModLoader.FABRIC)
.featured(true)
.build();
List<Version> versions = modrinth.versions()
.getByProject("sodium", options);

Use getVersionByNumber() to find a project version by its version number:

Version version = modrinth.versions()
.getVersionByNumber("sodium", "mc1.21.11-0.8.0");

Use resolveLatest() to get the first version matching the provided filters:

VersionSearchOptions options = VersionSearchOptions.builder()
.gameVersions("1.21.11")
.loaders(ModLoader.FABRIC)
.build();
Version latest = modrinth.versions()
.resolveLatest("sodium", options);

Versions can also be resolved from file hashes.

Version version = modrinth.versions()
.fromHash("file-hash");
List<Version> versions = modrinth.versions().fromHashes(
"file-hash-1",
"file-hash-2"
);

Fetch the dependencies of a version:

List<VersionDependency> dependencies = modrinth.versions()
.dependencies("version-id");
VersionsClient Methods10 available methods
get()

Fetches a version by its ID.

Returns: Version
getMany()

Fetches multiple versions by their IDs.

Returns: List<Version>
getByProject()

Fetches versions belonging to a project, optionally using filters.

Returns: List<Version>
getVersionByNumber()

Finds a project version by its version number.

Returns: Version
resolveLatest()

Returns the latest version matching the provided search options.

Returns: Version
fromHashes()

Resolves multiple versions from file hashes.

Returns: List<Version>
fromHash()

Resolves a version from a file hash.

Returns: Version
latestFromHashes()

Resolves the latest versions associated with multiple file hashes.

Returns: List<Version>
dependencies()

Fetches the dependencies of a version.

Returns: List<VersionDependency>