Skip to content

Files API Format

Kripesh Adhikari edited this page Oct 13, 2022 · 6 revisions

The Files API is used by the Profile Manager client to download and update the modpack files.

Files API Structure

Unlike the config.json and API formats, the Files API has no fixed key names. Instead, the root object has many children objects, where the key name of each child corresponds to a single file. The key name is the file name itself (including path, relative to the modpack directory). So for a file sodium.jar inside the mods folder, the key name would be mods/sodium.jar. The value of this key, which is an object, then describes the file itself.

Files API Required Fields

last_updated_version

Number, must be positive integer. The most recent version in which the file was updated.

Modrinth Provider

You can choose to use Modrinth to provide the files for your modpack. You can use a mix of different providers in your API, you don't need to get everything from Modrinth.

The url and hash fields are not required for the Modrinth Provider. The Profile Manager client will resolve both fields using the Modrinth API.

Required fields are as follows:

provider

This field is required if you want to use Modrinth. Set the value to modrinth.

"provider": "modrinth"

slug

The user-readable slug for the mod in Modrinth. So, for something like Sodium, whose URL is https://modrinth.com/mod/sodium, the value would be sodium

"slug": "lithium"

version

The user-readable version number of the mod that will be part of your modpack. Modrinth's API calls this value version_number. For releases with multiple files, only the "primary" file will be downloaded.

"version": "mc1.17-0.7.2"

CurseForge Provider

You can choose to use CurseForge to provide the files for your modpack. You can use a mix of different providers in your API, you don't need to get everything from CurseForge.

The url and hash fields are not required for the CurseForge Provider. The Profile Manager client will resolve both fields using the CurseForge API.

Required fields are as follows:

provider

This field is required if you want to use CurseForge. Set the value to curseforge.

"provider": "curseforge"

mod_id

The Mod ID (also called Project ID) for the mod in CurseForge. The value is an integer and is visible on the mod page in the "About Project" section.

"mod_id": 288953

file_id

The File ID of the mod file to download. The value is an integer and can be found at the very of the URL when downloading files from the CurseForge website.

"file_id": 4026753

Self-provided

This option is useful to provide config files or if you don't want to use Modrinth or CurseForge for your files. You will need to specify the url and hash. The provider fields is not required.

url

String. The URL to download the file. This must be a direct link. You can use a CDN like Cloudinary to get free direct link URLs. The URL file name does not need to match the file name specified in the object key.

hash

String. The SHA-256 hash of the file. The hash string must be prefixed by 0x.

Files API Optional Fields

condition

This object is used to define additional conditions for whether or not the client should download the file. Only the optimizer_mod condition is currently available. Example:

"condition": {
    "optimizer_mod": "caffeine_mc"
}

Here, the file will be downloaded only if the user has selected the caffeine_mc optimizer mod option.

You can use an array too, like this:

"condition": {
    "optimizer_mod": ["caffeine_mc", "lithium_only"]
}

Here, the file will be downloaded if the user has selected either the caffeine_mc or the lithium_only optimizer mod option.

ignore_hash_mismatch

When set to true, the profile manager will not re-download the file during file verification (even in the case of a hash mismatch). This can be useful for config files, which you have to provide during first install, but could be changed by the user to configure keybinds, etc.

There is an option in the settings menu to force verification, which can come in handy if the user modifies important parts of the config file.

Complete Example

Note: This example is only to give you an idea of the API Format rather than being a usable mod list.

{
  "mods/sodium-fabric-mc1.16.4-0.1.1-SNAPSHOT.jar": {
    "last_updated_version": 4,
    "url": "https://my_modpack.com/files/mods/1.16.5/sodium-fabric-mc1.16.4-0.1.1-SNAPSHOT.jar",
    "condition": {
      "optimizer_mod": "caffeine_mc"
    },
    "hash": "0xFA99EAF696AD93A6FF5ACEFE1EF8C8F49CBAE21EE9A676535D10997FE9C09119"
  },
  "mods/lithium-fabric-mc1.17-0.7.2.jar": {
    "last_updated_version": 4,
    "provider": "modrinth",
    "slug": "lithium",
    "version": "mc1.17-0.7.2",
    "condition": {
      "optimizer_mod": ["caffeine_mc", "lithium_only"]
    }
  },
  "mods/optifabric-1.9.6.jar": {
    "last_updated_version": 4,
    "url": "https://my_modpack.com/files/mods/1.16.5/optifabric-1.9.6.jar",
    "condition": {
      "optimizer_mod": "optifine"
    },
    "hash": "0xF1EA88E5C2C3D53C9BC197598B69680D8EBD58DDEE205345DBAB56C4B1EC66CA"
  },
  "mods/fabric-api-0.32.0+1.16.jar": {
    "last_updated_version": 4,
    "url": "https://my_modpack.com/files/mods/1.16.5/fabric-api-0.32.0_1.16.jar",
    "hash": "0xA7079732D33DF78367535B95094281F59D8E9602A0BE90889FE8CE7729D1124D"
  },
  "mods/CustomSkinLoader_Fabric-14.13-SNAPSHOT-214.jar": {
    "last_updated_version": 4,
    "provider": "curseforge",
    "mod_id": 286924,
    "file_id": 3695976
  },
  "CustomSkinLoader/CustomSkinLoader.json": {
    "last_updated_version": 1,
    "url": "https://my_modpack.com/files/CustomSkinLoader/CustomSkinLoader.json",
    "hash": "0x670294E8F2BC6EBC9C1604423F5A6C241449E8358EF2C8588C95E82A9871D70C"
  },
  "config/sodium/sodium.json5": {
    "ignore_hash_mismatch": true,
    "last_updated_version": 2,
    "url": "https://my_modpack.com/files/config/sodium.json5",
    "hash": "0x37D3F15B23E24CE62EA7673EBE2DCEEC26DCF91EC6F5B594697128AF773429FD"
  }
}