🎮 Hypixel Megawall API

📌 说明: 这是一个免费的公共API,用于获取Hypixel Megawall游戏数据。支持跨域请求,可直接在前端JavaScript中使用。

🔗 API地址

基础URL: https://megawalls.minecraft-cn.net/megawall_api.php

📋 请求参数

player (必需) - 玩家用户名
mode (可选) - 数据模式

🎯 模式1: 全部职业统计

获取玩家所有职业的综合数据

GET /megawall_api.php?player=玩家名&mode=all
请求示例:
https://megawalls.minecraft-cn.net/megawall_api.php?player=Notch&mode=all
返回数据:
{
    "success": true,
    "data": {
        "player_name": "Notch",
        "mode": "全部职业统计",
        "final_kills": 1250,
        "final_deaths": 800,
        "fk_d_ratio": 1.56,
        "wins": 450,
        "losses": 320,
        "w_l_ratio": 1.41,
        "total_class_score": 125000
    }
}

🎯 模式2: 当前职业统计

获取玩家当前选择职业的详细数据

GET /megawall_api.php?player=玩家名&mode=current
请求示例:
https://megawalls.minecraft-cn.net/megawall_api.php?player=Notch&mode=current
返回数据:
{
    "success": true,
    "data": {
        "player_name": "Notch",
        "mode": "当前职业统计",
        "current_class": "herobrine",
        "class_final_kills": 300,
        "class_final_deaths": 150,
        "class_fk_d_ratio": 2.00,
        "class_wins": 120,
        "class_losses": 80,
        "class_w_l_ratio": 1.50,
        "class_score": 25000
    }
}

🔍 API状态检测

检测镜像API是否有可用的API密钥

GET /megawall_api.php?action=status
请求示例:
https://megawalls.minecraft-cn.net/megawall_api.php?action=status
正常状态返回:
{
    "success": true,
    "data": {
        "status": "ok",
        "message": "镜像API有 5 个可用密钥",
        "available": true,
        "key_count": 5
    }
}
无密钥状态返回:
{
    "success": true,
    "data": {
        "status": "no_keys",
        "message": "镜像API没有可用的密钥",
        "available": false,
        "key_count": 0
    }
}

⚠️ 错误处理

API会根据不同情况返回相应的错误信息:

常见错误类型:

镜像API没有可用的API密钥 - 当前镜像服务暂不可用
该玩家使用了昵称模式(Nick),无法获取数据 - 玩家开启了昵称隐藏
请求过于频繁,请稍后重试 - 触发了API频率限制
玩家没有Megawall数据 - 玩家从未游玩过Megawall
错误响应示例:
{
    "success": false,
    "error": "镜像API没有可用的API密钥"
}

🧪 在线测试

测试API状态

测试API调用

💻 代码示例

JavaScript (Fetch API)

// 获取全部职业统计
fetch('https://megawalls.minecraft-cn.net/megawall_api.php?player=Notch&mode=all')
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            console.log('FK/D比率:', data.data.fk_d_ratio);
            console.log('W/L比率:', data.data.w_l_ratio);
            console.log('总职业分:', data.data.total_class_score);
        } else {
            console.error('错误:', data.error);
        }
    })
    .catch(error => console.error('请求失败:', error));

Python

import requests

# 获取当前职业统计
url = 'https://megawalls.minecraft-cn.net/megawall_api.php'
params = {'player': 'Notch', 'mode': 'current'}

response = requests.get(url, params=params)
data = response.json()

if data['success']:
    print(f"当前职业: {data['data']['current_class']}")
    print(f"FK/D比率: {data['data']['class_fk_d_ratio']}")
    print(f"W/L比率: {data['data']['class_w_l_ratio']}")
else:
    print(f"错误: {data['error']}")

cURL

# 获取全部职业统计
curl "https://megawalls.minecraft-cn.net/megawall_api.php?player=Notch&mode=all"

# 获取当前职业统计
curl "https://megawalls.minecraft-cn.net/megawall_api.php?player=Notch&mode=current"

📊 数据说明

FK/D比率: Final Kills / Final Deaths (击杀死亡比)
W/L比率: Wins / Losses (胜负比)
职业分: 职业经验值,反映玩家在该职业的熟练度
🎯 支持的Megawall职业:
Herobrine, Skeleton, Zombie, Enderman, Spider, Creeper, Witch, Arcanist, Shaman, Dreadlord, Golem, Moleman, Assassin, Hunter, Phoenix, Werewolf, Automaton, Cow, Squid, Pigman, Blaze