classModrinth#

class Modrinth(
user_agent: str | None = None,
*,
session: Session | None = None,
base_url: str = 'https://api.modrinth.com/v2',
)#

Modrinth. No API key is needed.

Parameters:
  • user_agent (str | None) – Identifies your tool. Modrinth asks every client to set one.

  • session (Session | None) – The session to use, instead of creating one. user_agent is then ignored.

  • base_url (str) – The API’s base URL.

base_url#

The API’s base URL.

search(
query: str,
*,
project_type: Literal['mod', 'modpack', 'resourcepack', 'shader'] = 'modpack',
game_version: str | None = None,
loader: str | None = None,
offset: int = 0,
limit: int = 20,
) → SearchResults#

Search Modrinth’s catalogue.

Parameters:
  • query (str) – The search text.

  • project_type (Literal['mod', 'modpack', 'resourcepack', 'shader']) – The kind of project to find.

  • game_version (str | None) – Only match this Minecraft version.

  • loader (str | None) – Only match this mod loader.

  • offset (int) – How many results to skip.

  • limit (int) – The maximum number of results to return.

Returns:

One page of results.

Raises:

NetworkError – Modrinth could not be reached.

Return type:

SearchResults

get_project(
ref: str | int,
*,
project_type: Literal['mod', 'modpack', 'resourcepack', 'shader'] = 'modpack',
) → Project#

Look up a project by id, slug or URL.

Parameters:
  • ref (str | int) – The project’s id, slug or web address.

  • project_type (Literal['mod', 'modpack', 'resourcepack', 'shader']) – Not used, because Modrinth’s ids are unique across types.

Returns:

The project.

Raises:

NetworkError – Modrinth could not be reached or does not know the project.

Return type:

Project

iter_releases(
project: Project,
*,
game_version: str | None = None,
loader: str | None = None,
release_only: bool = False,
) → Iterator[Release]#

Yield a project’s releases, newest first, reading pages as needed.

Parameters:
  • project (Project) – The project.

  • game_version (str | None) – Only list this Minecraft version.

  • loader (str | None) – Only list this mod loader.

  • release_only (bool) – Leave out alpha and beta releases.

Yields:

Each release, once.

Raises:

NetworkError – Modrinth could not be reached.