Python wrapper for Modrinth API with Pydantic models
Project description
modrinth_api_wrapper
modrinth_api_wrapper 是一个用于与 Modrinth API 交互的 Python 包。它提供了方便的客户端类和方法来访问 Modrinth 的各种 API 端点。
安装
你可以使用 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")
贡献
如果你有任何问题或建议,欢迎提交 Issue 或 Pull Request!
许可证
本项目采用 MIT 许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modrinth_api_wrapper-0.1.1.tar.gz.
File metadata
- Download URL: modrinth_api_wrapper-0.1.1.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c5151c00e30cff6e254c5596f0718fb242e998bb3174ed7a2564aa7af8ef54f
|
|
| MD5 |
3941afbd39eabbdad037a09f6c66091c
|
|
| BLAKE2b-256 |
f32b6ef3ad122739df8817916ac87dca6d3b9f9318fc8de8f78ec715640a4c1f
|
File details
Details for the file modrinth_api_wrapper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: modrinth_api_wrapper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb1c5e3a98de0e710acea418ba6d91ef8e7d96d0c121c2327bf19d6f1e68785c
|
|
| MD5 |
050aa78ec5ded875f8caa8ac81b93275
|
|
| BLAKE2b-256 |
4235b522bd5c0d9cf45c58aaa1377895ae0f14055569d5259282c7e4ab7d2c74
|