Skip to content

Instantly share code, notes, and snippets.

@OpenBagTwo
Created September 15, 2026 14:00
Show Gist options
  • Select an option

  • Save OpenBagTwo/b56fa56e6704af4774e7809199149857 to your computer and use it in GitHub Desktop.

Select an option

Save OpenBagTwo/b56fa56e6704af4774e7809199149857 to your computer and use it in GitHub Desktop.
Python method to tag your release candidate versions for a full release
"""For a full example see:
https://github.com/OpenBagTwo/AngerLocalBeehive/blob/main/notebooks/Tagging%20Modrinth%20Projects%20for%20The%20Copper%20Age.ipynb
"""
import json
from os import environ
import requests
base_url = "https://api.modrinth.com/v2/"
auth_token = environ["MODRINTH_TOKEN"]
header = {"Authorization": auth_token}
def tag_compatible(
version_id: str, game_version: str, rc_version: str | None = None
) -> None:
"""
Tag a version as compatible with the specified Minecraft version
Parameters
----------
version_id : str
The ID of the project version to tag
game_version: str
The version of Minecraft to add to the list of compatible tags
rc_version: str, optional
If specified, this method will first check to make sure that
the project version was already tagged as compatible with the
specified release candidate
"""
existing_versions = json.loads(
requests.get(base_url + f"version/{version_id}", headers=header).text
)["game_versions"]
assert game_version not in existing_versions, "Already tagged, nothing doing"
if rc_version and rc_version not in existing_versions:
raise ValueError(
f"{version_id} wasn't tagged compatible with {rc_version}."
" Did you grab the wrong version ID?"
)
response = requests.patch(
base_url + f"version/{version_id}",
headers=header,
json={
"game_versions": existing_versions + [game_version],
"featured": True, # bonus
},
)
if response.status_code >= 300: # any 200 is fine
print(response.status_code)
raise ValueError(json.loads(response.text))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment