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:
- 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,
- sort: Literal['relevance', 'downloads', 'popularity', 'newest', 'updated'] = 'relevance',
- offset: int = 0,
- limit: int = 20,
Search Modrinth’s catalogue.
Modrinth serves 100 results a page; larger limits read several pages.
- 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.
sort (Literal['relevance', 'downloads', 'popularity', 'newest', 'updated']) – How to order the results.
offset (int) – How many results to skip.
limit (int) – The maximum number of results to return.
- Returns:
The results.
- Raises:
NetworkError – Modrinth could not be reached.
- Return type:
- get_project( ) Project#
Look up a project by id, slug or URL.
- Parameters:
- Returns:
The project.
- Raises:
NetworkError – Modrinth could not be reached or does not know the project.
- Return type:
- get_projects( ) dict[str, Project]#
Look up several projects by id or slug, in as few requests as possible.
- Parameters:
- Returns:
Each project Modrinth knows, keyed by the id or slug asked for. Unknown ones are left out.
- Raises:
NetworkError – Modrinth could not be reached.
- Return type:
- iter_releases(
- project: Project,
- *,
- game_version: str | None = None,
- loader: str | None = None,
- release_only: bool = False,
Yield a project’s releases, newest first, reading pages as needed.
- Parameters:
- Yields:
Each release, once.
- Raises:
NetworkError – Modrinth could not be reached.
- get_release(
- release_id: str,
Look up a release by id.
- Parameters:
release_id (str) – The version’s id.
- Returns:
The release.
- Raises:
NetworkError – Modrinth could not be reached or does not know the id.
- Return type:
- authors(
- project: Project,
Return the members of a project’s team, the owner first.
- Parameters:
project (Project) – The project.
- Returns:
Their user names.
- Raises:
NetworkError – Modrinth could not be reached or does not know it.
- Return type:
- changelog(
- release: Release,
Return what changed in a release. Modrinth changelogs are Markdown.
- Parameters:
release (Release) – The release.
- Returns:
The changelog, or an empty string if there is none.
- Raises:
NetworkError – Modrinth could not be reached or does not know it.
- Return type:
- identify(
- paths: Iterable[Path | str],
- *,
- progress: Callable[[Progress], None] | None = None,
- cancel: CancelToken | None = None,
Find the releases that files came from, by their SHA-1 hashes.
- Parameters:
- Returns:
The release of each file Modrinth knows. Other files are left out.
- Raises:
OSError – A file could not be read.
NetworkError – Modrinth could not be reached.
Cancelled –
cancelwas triggered.
- Return type: