| 项目 | 值 |
|---|---|
| Base URL | https://4dwin.me |
| 格式 | JSON / UTF-8 |
| 鉴权 | 无需(公开只读);如已配置 API Key,请带 key= 参数 |
| 缓存 | 常规 60 秒;有彩种正在开彩(live:true)时自动缩短为 12 秒(近似实时同步) |
| 历史数据 | 本站自建开彩数据库,可查以往开彩记录(见 /api/4d/history) |
| 域名说明 | chat.claw99.ai 已不提供 4D 接口(返回 404),请使用上表 Base URL |
| CORS | 允许跨域 GET |
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/4d/list | 可用彩种清单 |
| GET | /api/4d/latest | 最新成绩(JSON) |
| GET | /api/4d/text | 最新成绩(纯文本,便于直接显示/转发) |
| GET | /api/4d/history | 历史开彩记录(本地库,可按彩种/日期筛选、分页) |
| GET | /api/4d/history-dates | 有记录的日期清单(用于日期选择器) |
| 参数 | 必填 | 说明 | 示例 |
|---|---|---|---|
codes | 否 | 彩种代号,逗号分隔;留空=全部 | M,PMP,ST,SG |
key | 否 | API Key(若服务端已启用) | abcd1234 |
code | 否 | 历史接口:彩种代号,逗号分隔;留空=全部 | M,L |
date | 否 | 历史接口:按开彩日期筛选 | 2026-09-17 |
limit | 否 | 历史接口:每页条数(默认 30,最大 200) | 50 |
offset | 否 | 历史接口:偏移量(分页用) | 30 |
| 代号 | 彩种 | 代号 | 彩种 |
|---|---|---|---|
M | Magnum 4D 马来西亚 | STC | Sandakan 4D 沙巴 |
PMP | Da Ma Cai 马来西亚 | EE | Sabah 88 4D 沙巴 |
ST | Sports Toto 4D 马来西亚 | CS | Special Cash Sweep 砂拉越 |
SG | Singapore Pools 4D 新加坡 | L / WB / P / 6L | 8LUCKY / 9 Winbox / Perdana / Lotto 6D |
cURL
curl "https://4dwin.me/api/4d/latest?codes=M,SG"
JavaScript
fetch("https://4dwin.me/api/4d/latest?codes=M").then(r=>r.json()).then(d=>{
const r = d.results[0];
console.log(r.label, r.draw_id, r.first, r.second, r.third);
});
PHP
$json = file_get_contents("https://4dwin.me/api/4d/latest?codes=M");
$d = json_decode($json, true);
echo $d["results"][0]["first"]; // 首奖
Python
import requests
d = requests.get("https://4dwin.me/api/4d/latest?codes=M").json()
print(d["results"][0]["first"])
历史记录(最近 5 条 Magnum / 8LUCKY)
curl "https://4dwin.me/api/4d/history?code=M,L&limit=5"
# Python
import requests
d = requests.get("https://4dwin.me/api/4d/history",
params={"code": "M", "limit": 10}).json()
for r in d["records"]:
print(r["draw_date"], r["draw_id"], r["first"], r["second"], r["third"])
{
"ok": true,
"count": 1,
"results": [
{
"code": "M", // 彩种代号
"label": "Magnum 4D 马来西亚", // 显示名
"draw_id": "423/26", // 期号
"draw_date": "2026-09-16", // 开彩日期
"day": "Wed", // 星期
"live": false, // 是否开彩中
"first": "6087", // 首奖
"second": "0781", // 二奖
"third": "3815", // 三奖
"special": ["1207","0005",...], // 特别奖(10 个)
"consolation": ["3187","7591",...] // 安慰奖(10 个)
}
]
}
{
"ok": true,
"count": 1,
"text": "🎰 Magnum 4D 马来西亚\n期号 423/26 | 2026-09-16 (Wed)\n\n🥇 首奖 6087\n🥈 二奖 0781\n🥉 三奖 3815\n..."
}
{
"ok": true,
"total": 128, // 符合筛选条件的总条数(分页用)
"count": 2, // 本次返回条数
"records": [
{
"code": "L",
"name": "8LUCKY",
"session": "19:30", // 场次(多场次彩种);单场为空 ""
"draw_id": "4348", // 期号(部分彩种无期号则为空)
"draw_date": "2026-09-16",
"day": "Wed",
"n1": "0992", "n2": "4133", "n3": "1731",
"special": ["4358","0153",...],
"consolation": ["6117","3615",...],
"live": false,
"updated_at": "2026-09-17 15:52:10"
}
]
}
// 日期清单
GET /api/4d/history-dates?code=L
{"ok": true, "dates": [{"date": "2026-09-17", "count": 4}, {"date": "2026-09-16", "count": 2}]}
0781),对接时请按字符串处理,勿转数字。results 可能为空数组,请判空。live:true)的场次号码会陆续补全,建议客户端在有 live 时缩短轮询间隔(如 10 秒)。