Skip to main content

A Python API client for the Modrinth API

Project description

modrinth4py

A Python API client for the Modrinth API.

Installation

pip install modrinth4py

Usage

from modrinth4py import ModrinthClient, NewProject, SideSupport, ProjectType

client = ModrinthClient(token="your-modrinth-pat")

project = client.get_project("sodium")
print(project["title"])

Creating a project

from modrinth4py import NewProject, SideSupport, ProjectType, RequestedStatus

new_project = NewProject(
    slug="my-mod",
    title="My Mod",
    description="A short description",
    categories=["utility"],
    client_side=SideSupport.REQUIRED,
    server_side=SideSupport.OPTIONAL,
    body="## My Mod\nLong-form description here.",
    project_type=ProjectType.MOD,
)

result = client.create_project(new_project)

Uploading a version

from pathlib import Path
from modrinth4py import NewVersion, VersionType

version = NewVersion(
    name="1.0.0",
    version_number="1.0.0",
    project_id="your-id",
    game_versions=["1.21"],
    loaders=["fabric"],
    version_type=VersionType.RELEASE,
    changelog="Initial release.",
)

client.create_version(version, file_paths=[Path("my-mod-1.0.0.jar")])

Modifying a project

from modrinth4py import ModrinthClient, ProjectUpdate

client.modify_project("your-slug", ProjectUpdate(
    discord_url="https://discord.gg/your-invite",
    license_id="MIT",
))

Parallel requests

projects = ModrinthClient.parallel_requests([
    lambda: client.get_project("sodium"),
    lambda: client.get_project("lithium"),
    lambda: client.get_project("iris"),
])

Logging

modrinth4py uses Python's standard logging module under the modrinth4py.client logger. Pass debug=True to ModrinthClient to enable debug output, or configure your own handler:

import logging
logging.basicConfig(level=logging.DEBUG)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modrinth4py-0.0.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modrinth4py-0.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file modrinth4py-0.0.1.tar.gz.

File metadata

  • Download URL: modrinth4py-0.0.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for modrinth4py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 261f75d92f204a5ee0ec5c90404b391f1e1e86e0c8dc60248d240b78970a61c7
MD5 5a231a6c4229edafb6e3db5c1f0b15d4
BLAKE2b-256 aa937ad5531825b9663a0a94f77ad7bbd2359c5b3678fb81a23c11bdb5cd2de8

See more details on using hashes here.

Provenance

The following attestation bundles were made for modrinth4py-0.0.1.tar.gz:

Publisher: publish.yml on rotgruengelb/modrinth4py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file modrinth4py-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: modrinth4py-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for modrinth4py-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe6f1685ad7cf5214b18d3ffa29fb46250e990e628441c68d7570537a2cccfd
MD5 f0035b81e396bc74aa59be08f1f75285
BLAKE2b-256 daa40ab4963168069842c985c6741ca6033849ee1a8a3af0d6d49851db492c2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for modrinth4py-0.0.1-py3-none-any.whl:

Publisher: publish.yml on rotgruengelb/modrinth4py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page