Skip to main content

modrinth_api_wrapper

modrinth-api-wrapper

modrinth_api_wrapper 是一个用于与 Modrinth API 交互的 Python 包。它提供了方便的客户端类和方法来访问 Modrinth 的各种 API 端点。\

特别指出提供了所有返回值的 Pydantic 封装,便于调用。

安装

你可以使用 pip 来安装这个包:

pip install modrinth_api_wrapper

使用示例

以下是一些使用 modrinth_api_wrapper 的示例代码,展示了如何与 Modrinth API 进行交互。

初始化客户端

首先,你需要初始化一个 Client 对象来与 API 进行交互:

from modrinth_api_wrapper import Client

client = Client()

搜索项目

你可以通过关键字搜索 Modrinth 上的项目:

client.search_project(query="sodium")

获取项目信息

通过项目 ID 或 slug 获取项目的详细信息:

client.get_project(project_id="AANobbMI")

# 或者通过 slug 获取
client.get_project(project_id="fabric-api")

批量获取项目信息

你可以通过多个项目 ID 或 slug 批量获取项目信息:

client.get_projects(ids=["AANobbMI", "P7dR8mSH"])

# 或者通过 slug 获取
client.get_projects(ids=["fabric-api", "sodium"])

获取项目的版本信息

通过项目 ID 获取项目的所有版本:

client.list_project_versions(project_id="AANobbMI")

获取特定版本信息

通过版本 ID 获取特定版本的详细信息:

client.get_version(version_id="3auffiOJ")

批量获取版本信息

通过多个版本 ID 批量获取版本信息:

client.get_versions(version_ids=["3auffiOJ", "mnEhtGuH"])

通过哈希值获取版本信息

你可以通过文件的 SHA1 或 SHA512 哈希值获取对应的版本信息:

example_sha1 = "9e1ccb3b136cff0715004bbd418c66eb38bb8383"
example_sha512 = "5677d011800d88c5259a2a3c82d0e90b5dec83a7505fc7502a68a2ff7f21834564f02764dc8813f910bd768bff253892cf54ce7d3300d6d0bbc8b592db829251"

# sha1
client.get_version_from_hash(sha1=example_sha1)

# 或者使用 SHA512
client.get_version_from_hash(sha512=example_sha512)

批量通过哈希值获取版本信息

你可以通过多个哈希值批量获取版本信息:

versions = client.get_versions_from_hashes(hashes=[example_sha1], algorithm=Algorithm.SHA1)
for version in versions.values():
    print(version)

# 或者使用 SHA512
client.get_versions_from_hashes(hashes=[example_sha512], algorithm=Algorithm.SHA512)

获取最新版本信息

通过哈希值、加载器和游戏版本获取最新的版本信息:

# sha1
client.get_latest_version_from_hash(example_sha1, loaders=["fabric"], game_versions=["1.16.5"])


# 或者使用 SHA512
client.get_latest_version_from_hash(sha512=example_sha512, loaders=["fabric"], game_versions=["1.16.5"])

批量获取最新版本信息

通过多个哈希值、加载器和游戏版本批量获取最新的版本信息:

versions = client.get_latest_versions_from_hashes(hashes=[example_sha1], algorithm=Algorithm.SHA1, loaders=["fabric"], game_versions=["1.16.5"])


# 或者使用 SHA512

client.get_latest_versions_from_hashes(hashes=[example_sha512], algorithm=Algorithm.SHA512, loaders=["fabric"], game_versions=["1.16.5"])

获取标签信息

你可以获取 Modrinth 平台上的各种标签信息,例如类别、加载器、游戏版本等:

tags = client.get_tag(tag="category")

tags = client.get_tag(tag="loader")

TODO

  • TAG Model
  • User API

贡献

如果你有任何问题或建议,欢迎提交 Issue 或 Pull Request!

许可证

本项目采用 MIT 许可证。

Metadata

Release files for modrinth-api-wrapper 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modrinth-api-wrapper 1.0.0
File Size Uploaded Provenance Actions
modrinth_api_wrapper-1.0.0.tar.gz 23.5 kB Without provenance Details for modrinth_api_wrapper-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modrinth-api-wrapper 1.0.0
File Interpreter ABI Platform Actions
modrinth_api_wrapper-1.0.0-py3-none-any.whl Python 3 none any Details for modrinth_api_wrapper-1.0.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / modrinth_api_wrapper-1.0.0.tar.gz

Download URL modrinth_api_wrapper-1.0.0.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
47c97c5c44592ecc1baf4153a6753d7bee65da3c0969be8839e045502c2224cf
BLAKE2b-256 checksum
How to use checksums
3137e1b41e6203c7e22c544cd8fb0cf8a585d42096015747c2ea7bcc5561c58e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.23

Release files / modrinth_api_wrapper-1.0.0-py3-none-any.whl

Download URL modrinth_api_wrapper-1.0.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8ecc41d1f02467cbda54607a09254a332eeb7275711a6446b9ff56947f9e638
BLAKE2b-256 checksum
How to use checksums
8b2bd5f1e940091ec0c5a7df58666f8043cbc6e4f482126e5b0b5905d8eb59e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.23

Security for modrinth-api-wrapper 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page