Skip to main content

监控 Mojang API 各服务状态的 Python 库

Project description

Mojang API Monitor

PyPI Python License

监控 Mojang API 各服务状态的 Python 库。当 Minecraft 玩家遇到登录错误时,可用此工具快速判断是否为 Mojang 服务器问题。

此项目是 Mojang-API-Monitor C# NuGet 包的 Python 移植版。

功能

  • 监控 9 个 Mojang 服务的在线状态
  • 支持并行检测,毫秒级完成全部检查
  • 自动 DNS 降级(部分服务 http 解析失败时自动尝试 https)
  • 支持 HTTP/HTTPS 代理
  • 支持自定义服务列表
  • 支持 JSON 序列化/反序列化
  • 提供命令行工具和 Python API 两种使用方式

监控的服务

# 服务名称 URL
1 Minecraft.net https://minecraft.net/
2 Session Minecraft http://session.minecraft.net/
3 Account Mojang http://account.mojang.com/
4 Auth Mojang https://auth.mojang.com/
5 Skins Minecraft http://skins.minecraft.net/
6 Authserver Mojang https://authserver.mojang.com/
7 Sessionserver Mojang https://sessionserver.mojang.com/
8 API Mojang https://api.mojang.com/
9 Textures Minecraft http://textures.minecraft.net/

安装

pip install mojang-api-monitor

使用

Python API

from mojang_api_monitor import MojangMonitor

# 创建监控器(支持代理)
monitor = MojangMonitor(
    proxies={"http": "http://127.0.0.1:7897", "https": "http://127.0.0.1:7897"}
)

# 检查所有服务(并行)
status = monitor.check_all_services()

# 遍历结果
for svc in status.services:
    print(f"{svc.name:20s} {svc.status:8s} {svc.response_time_ms:>6.0f}ms")

# 导出 JSON
print(status.to_dict())

命令行

# 基础检查
mojang-api-monitor

# 使用代理
mojang-api-monitor --proxy-http http://127.0.0.1:7897

# 导出 JSON
mojang-api-monitor -o status.json

# 自定义超时和并发
mojang-api-monitor -t 15 -w 5

JSON 输出格式

{
  "services": [
    {
      "name": "Minecraft.net",
      "url": "https://minecraft.net/",
      "display_url": "https://minecraft.net",
      "status": "ONLINE",
      "last_checked": "2025-05-29T16:41:41.0165483Z",
      "response_time_ms": 3249.0
    }
  ],
  "timestamp": "2025-05-29T16:41:37.7543238Z"
}

开发

# 克隆
git clone https://github.com/PCL-Community/Mojang-API-Monitor.git
cd Mojang-API-Monitor

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

# 构建
python -m build

依赖

  • Python >= 3.8
  • requests >= 2.25

许可证

MIT License

免责声明

本项目不隶属于 Mojang Studios 或 Microsoft。Minecraft、Mojang 是 Mojang Studios 的商标。

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

mojang_api_monitor-1.0.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

mojang_api_monitor-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mojang_api_monitor-1.0.1.tar.gz.

File metadata

  • Download URL: mojang_api_monitor-1.0.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mojang_api_monitor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d05e194b3fb2c7629b7c49e3df3e4067c397d81c50b4f63af86ca8cf8f7c3f2c
MD5 7abef64968e2e2b8ec19118ee1837353
BLAKE2b-256 30c7b6f4396b7064bdb4a2ac2ad1c71931f15828b353cdec87ce9ea28e3b6828

See more details on using hashes here.

File details

Details for the file mojang_api_monitor-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mojang_api_monitor-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48ecc9912ed5fefe116ff3037f2502020e48e60a14cc7315c7b85985f49261bd
MD5 defb1b828a600c547f8947fd851e8c2d
BLAKE2b-256 4e148f6c29be32494355dfbbd6296b10928e79318681bfd9abec77f52f6b3fec

See more details on using hashes here.

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