modrinth-api-wrapper


Namemodrinth-api-wrapper JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryPython wrapper for Modrinth API with Pydantic models
upload_time2025-01-23 16:03:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords api mcinecraft modrinth python wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # modrinth_api_wrapper

![modrinth-api-wrapper](https://socialify.git.ci/mcmod-info-mirror/modrinth-api-wrapper/image?description=1&font=Inter&forks=1&issues=1&language=1&name=1&owner=1&pattern=Overlapping+Hexagons&stargazers=1&theme=Dark)

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

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

## 安装

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

```sh
pip install modrinth_api_wrapper
```

## 使用示例

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

### 初始化客户端

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

```python
from modrinth_api_wrapper import Client

client = Client()
```

### 搜索项目

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

```python
client.search_project(query="sodium")
```

### 获取项目信息

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

```python
client.get_project(project_id="AANobbMI")

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

### 批量获取项目信息

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

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

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

### 获取项目的版本信息

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

```python
client.list_project_versions(project_id="AANobbMI")
```

### 获取特定版本信息

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

```python
client.get_version(version_id="3auffiOJ")
```

### 批量获取版本信息

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

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

### 通过哈希值获取版本信息

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

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

# sha1
client.get_version_from_hash(sha1=example_sha1)

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

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

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

```python
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)
```

### 获取最新版本信息

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

```python
# 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"])
```

### 批量获取最新版本信息

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

```python
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 平台上的各种标签信息,例如类别、加载器、游戏版本等:

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

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

## TODO

- [ ] TAG Model
- [ ] User API

## 贡献

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

## 许可证

本项目采用 MIT 许可证。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "modrinth-api-wrapper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "api, mcinecraft, modrinth, python, wrapper",
    "author": null,
    "author_email": "z0z0r4 <z0z0r4@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/31/37/e1b41e6203c7e22c544cd8fb0cf8a585d42096015747c2ea7bcc5561c58e/modrinth_api_wrapper-1.0.0.tar.gz",
    "platform": null,
    "description": "# modrinth_api_wrapper\n\n![modrinth-api-wrapper](https://socialify.git.ci/mcmod-info-mirror/modrinth-api-wrapper/image?description=1&font=Inter&forks=1&issues=1&language=1&name=1&owner=1&pattern=Overlapping+Hexagons&stargazers=1&theme=Dark)\n\n`modrinth_api_wrapper` \u662f\u4e00\u4e2a\u7528\u4e8e\u4e0e Modrinth API \u4ea4\u4e92\u7684 Python \u5305\u3002\u5b83\u63d0\u4f9b\u4e86\u65b9\u4fbf\u7684\u5ba2\u6237\u7aef\u7c7b\u548c\u65b9\u6cd5\u6765\u8bbf\u95ee Modrinth \u7684\u5404\u79cd API \u7aef\u70b9\u3002\\\n\n\u7279\u522b\u6307\u51fa\u63d0\u4f9b\u4e86\u6240\u6709\u8fd4\u56de\u503c\u7684 Pydantic \u5c01\u88c5\uff0c\u4fbf\u4e8e\u8c03\u7528\u3002\n\n## \u5b89\u88c5\n\n\u4f60\u53ef\u4ee5\u4f7f\u7528 `pip` \u6765\u5b89\u88c5\u8fd9\u4e2a\u5305\uff1a\n\n```sh\npip install modrinth_api_wrapper\n```\n\n## \u4f7f\u7528\u793a\u4f8b\n\n\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4f7f\u7528 modrinth_api_wrapper \u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4e0e Modrinth API \u8fdb\u884c\u4ea4\u4e92\u3002\n\n### \u521d\u59cb\u5316\u5ba2\u6237\u7aef\n\n\u9996\u5148\uff0c\u4f60\u9700\u8981\u521d\u59cb\u5316\u4e00\u4e2a Client \u5bf9\u8c61\u6765\u4e0e API \u8fdb\u884c\u4ea4\u4e92\uff1a\n\n```python\nfrom modrinth_api_wrapper import Client\n\nclient = Client()\n```\n\n### \u641c\u7d22\u9879\u76ee\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u5173\u952e\u5b57\u641c\u7d22 Modrinth \u4e0a\u7684\u9879\u76ee\uff1a\n\n```python\nclient.search_project(query=\"sodium\")\n```\n\n### \u83b7\u53d6\u9879\u76ee\u4fe1\u606f\n\n\u901a\u8fc7\u9879\u76ee ID \u6216 slug \u83b7\u53d6\u9879\u76ee\u7684\u8be6\u7ec6\u4fe1\u606f\uff1a\n\n```python\nclient.get_project(project_id=\"AANobbMI\")\n\n# \u6216\u8005\u901a\u8fc7 slug \u83b7\u53d6\nclient.get_project(project_id=\"fabric-api\")\n```\n\n### \u6279\u91cf\u83b7\u53d6\u9879\u76ee\u4fe1\u606f\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u591a\u4e2a\u9879\u76ee ID \u6216 slug \u6279\u91cf\u83b7\u53d6\u9879\u76ee\u4fe1\u606f\uff1a\n\n```python\nclient.get_projects(ids=[\"AANobbMI\", \"P7dR8mSH\"])\n\n# \u6216\u8005\u901a\u8fc7 slug \u83b7\u53d6\nclient.get_projects(ids=[\"fabric-api\", \"sodium\"])\n```\n\n### \u83b7\u53d6\u9879\u76ee\u7684\u7248\u672c\u4fe1\u606f\n\n\u901a\u8fc7\u9879\u76ee ID \u83b7\u53d6\u9879\u76ee\u7684\u6240\u6709\u7248\u672c\uff1a\n\n```python\nclient.list_project_versions(project_id=\"AANobbMI\")\n```\n\n### \u83b7\u53d6\u7279\u5b9a\u7248\u672c\u4fe1\u606f\n\n\u901a\u8fc7\u7248\u672c ID \u83b7\u53d6\u7279\u5b9a\u7248\u672c\u7684\u8be6\u7ec6\u4fe1\u606f\uff1a\n\n```python\nclient.get_version(version_id=\"3auffiOJ\")\n```\n\n### \u6279\u91cf\u83b7\u53d6\u7248\u672c\u4fe1\u606f\n\n\u901a\u8fc7\u591a\u4e2a\u7248\u672c ID \u6279\u91cf\u83b7\u53d6\u7248\u672c\u4fe1\u606f\uff1a\n\n```python\nclient.get_versions(version_ids=[\"3auffiOJ\", \"mnEhtGuH\"])\n```\n\n### \u901a\u8fc7\u54c8\u5e0c\u503c\u83b7\u53d6\u7248\u672c\u4fe1\u606f\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u6587\u4ef6\u7684 SHA1 \u6216 SHA512 \u54c8\u5e0c\u503c\u83b7\u53d6\u5bf9\u5e94\u7684\u7248\u672c\u4fe1\u606f\uff1a\n\n```python\nexample_sha1 = \"9e1ccb3b136cff0715004bbd418c66eb38bb8383\"\nexample_sha512 = \"5677d011800d88c5259a2a3c82d0e90b5dec83a7505fc7502a68a2ff7f21834564f02764dc8813f910bd768bff253892cf54ce7d3300d6d0bbc8b592db829251\"\n\n# sha1\nclient.get_version_from_hash(sha1=example_sha1)\n\n# \u6216\u8005\u4f7f\u7528 SHA512\nclient.get_version_from_hash(sha512=example_sha512)\n```\n\n### \u6279\u91cf\u901a\u8fc7\u54c8\u5e0c\u503c\u83b7\u53d6\u7248\u672c\u4fe1\u606f\n\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u591a\u4e2a\u54c8\u5e0c\u503c\u6279\u91cf\u83b7\u53d6\u7248\u672c\u4fe1\u606f\uff1a\n\n```python\nversions = client.get_versions_from_hashes(hashes=[example_sha1], algorithm=Algorithm.SHA1)\nfor version in versions.values():\n    print(version)\n\n# \u6216\u8005\u4f7f\u7528 SHA512\nclient.get_versions_from_hashes(hashes=[example_sha512], algorithm=Algorithm.SHA512)\n```\n\n### \u83b7\u53d6\u6700\u65b0\u7248\u672c\u4fe1\u606f\n\n\u901a\u8fc7\u54c8\u5e0c\u503c\u3001\u52a0\u8f7d\u5668\u548c\u6e38\u620f\u7248\u672c\u83b7\u53d6\u6700\u65b0\u7684\u7248\u672c\u4fe1\u606f\uff1a\n\n```python\n# sha1\nclient.get_latest_version_from_hash(example_sha1, loaders=[\"fabric\"], game_versions=[\"1.16.5\"])\n\n\n# \u6216\u8005\u4f7f\u7528 SHA512\nclient.get_latest_version_from_hash(sha512=example_sha512, loaders=[\"fabric\"], game_versions=[\"1.16.5\"])\n```\n\n### \u6279\u91cf\u83b7\u53d6\u6700\u65b0\u7248\u672c\u4fe1\u606f\n\n\u901a\u8fc7\u591a\u4e2a\u54c8\u5e0c\u503c\u3001\u52a0\u8f7d\u5668\u548c\u6e38\u620f\u7248\u672c\u6279\u91cf\u83b7\u53d6\u6700\u65b0\u7684\u7248\u672c\u4fe1\u606f\uff1a\n\n```python\nversions = client.get_latest_versions_from_hashes(hashes=[example_sha1], algorithm=Algorithm.SHA1, loaders=[\"fabric\"], game_versions=[\"1.16.5\"])\n\n\n# \u6216\u8005\u4f7f\u7528 SHA512\n\nclient.get_latest_versions_from_hashes(hashes=[example_sha512], algorithm=Algorithm.SHA512, loaders=[\"fabric\"], game_versions=[\"1.16.5\"])\n```\n\n### \u83b7\u53d6\u6807\u7b7e\u4fe1\u606f\n\n\u4f60\u53ef\u4ee5\u83b7\u53d6 Modrinth \u5e73\u53f0\u4e0a\u7684\u5404\u79cd\u6807\u7b7e\u4fe1\u606f\uff0c\u4f8b\u5982\u7c7b\u522b\u3001\u52a0\u8f7d\u5668\u3001\u6e38\u620f\u7248\u672c\u7b49\uff1a\n\n```python\ntags = client.get_tag(tag=\"category\")\n\ntags = client.get_tag(tag=\"loader\")\n```\n\n## TODO\n\n- [ ] TAG Model\n- [ ] User API\n\n## \u8d21\u732e\n\n\u5982\u679c\u4f60\u6709\u4efb\u4f55\u95ee\u9898\u6216\u5efa\u8bae\uff0c\u6b22\u8fce\u63d0\u4ea4 Issue \u6216 Pull Request\uff01\n\n## \u8bb8\u53ef\u8bc1\n\n\u672c\u9879\u76ee\u91c7\u7528 MIT \u8bb8\u53ef\u8bc1\u3002\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for Modrinth API with Pydantic models",
    "version": "1.0.0",
    "project_urls": {
        "Documentation": "https://github.com/mcmod-info-mirror/modrinth-api-wrapper",
        "Homepage": "https://github.com/mcmod-info-mirror/modrinth-api-wrapper",
        "Issues": "https://github.com/mcmod-info-mirror/modrinth-api-wrapper/issues",
        "Repository": "https://github.com/mcmod-info-mirror/modrinth-api-wrapper"
    },
    "split_keywords": [
        "api",
        " mcinecraft",
        " modrinth",
        " python",
        " wrapper"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b2bd5f1e940091ec0c5a7df58666f8043cbc6e4f482126e5b0b5905d8eb59e8",
                "md5": "fc5ff898219190cc440edf1a16730ee9",
                "sha256": "b8ecc41d1f02467cbda54607a09254a332eeb7275711a6446b9ff56947f9e638"
            },
            "downloads": -1,
            "filename": "modrinth_api_wrapper-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc5ff898219190cc440edf1a16730ee9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8235,
            "upload_time": "2025-01-23T16:03:57",
            "upload_time_iso_8601": "2025-01-23T16:03:57.757268Z",
            "url": "https://files.pythonhosted.org/packages/8b/2b/d5f1e940091ec0c5a7df58666f8043cbc6e4f482126e5b0b5905d8eb59e8/modrinth_api_wrapper-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3137e1b41e6203c7e22c544cd8fb0cf8a585d42096015747c2ea7bcc5561c58e",
                "md5": "0333dfe66177bdae9ecf6121dd4ed2d7",
                "sha256": "47c97c5c44592ecc1baf4153a6753d7bee65da3c0969be8839e045502c2224cf"
            },
            "downloads": -1,
            "filename": "modrinth_api_wrapper-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0333dfe66177bdae9ecf6121dd4ed2d7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 23543,
            "upload_time": "2025-01-23T16:03:58",
            "upload_time_iso_8601": "2025-01-23T16:03:58.783739Z",
            "url": "https://files.pythonhosted.org/packages/31/37/e1b41e6203c7e22c544cd8fb0cf8a585d42096015747c2ea7bcc5561c58e/modrinth_api_wrapper-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-23 16:03:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mcmod-info-mirror",
    "github_project": "modrinth-api-wrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "modrinth-api-wrapper"
}
        
Elapsed time: 0.43879s