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.2.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.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: modrinth4py-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0791822c4e3508bb1ec13a755dd1fbba42f7f72b7e137708c8cbf9d30c7dc293
MD5 731af9f1b14374b429ef831f8f69da27
BLAKE2b-256 5f64dc5deac2aea5baebd94fa1bbc56f24a5abb000f0d1e26a576fe3a499e7de

See more details on using hashes here.

Provenance

The following attestation bundles were made for modrinth4py-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: modrinth4py-0.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4efea8ae380722e842f43268a7ed00b706d2ba5e29ddc25e453e14f7321f4994
MD5 96bb59317440715bafc0744f85c12955
BLAKE2b-256 8e67565ae8ba09ec04e6484c49aeea8d5fe26a5bde8df399f6c31c17c97f6d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for modrinth4py-0.0.2-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