杀戮尖塔2 (STS2) 开发者
用 Spire Codex 的数据构建工具、机器人和内容。一切免费开放。
提示框组件
为任何网站添加 Wowhead 风格的卡牌、遗物和药水悬停提示。一个 script 标签,零依赖。
安装
<script src="https://spire-codex.com/widget/spire-codex-tooltip.js"></script>语法
[[Strike]]卡牌提示(默认类型)[[card:Bash]]卡牌(显式)[[relic:Burning Blood]]遗物[[potion:Fire Potion]]药水[[character:Ironclad]]角色[[monster:Jaw Worm]]怪物[[power:Strength]]能力[[event:Neow]]事件[[encounter:Lagavulin]]遭遇[[enchantment:Sharp]]附魔[[keyword:Exhaust]]关键词[[orb:Lightning]]能量球[[affliction:Bound]]状态[[achievement:Minimalist]]成就JavaScript API
SpireCodex.scan()重新扫描页面中的新 [[...]] 模式(用于 SPA)SpireCodex.scan(element)扫描指定的 DOM 元素更新日志组件
嵌入一个紧凑的交互式更新日志查看器,展示 Spire Codex 的更新历史并支持切换版本。
安装
<div id="scx-changelog"></div>
<script src="https://spire-codex.com/widget/spire-codex-changelog.js"></script>data-version="1.0.4"显示指定版本(默认:最新)REST API
完整游戏数据库可通过公开 REST API 访问。无需认证:按 IP 的网站配额足以覆盖浏览和零散调用,无密钥的 API 使用适用下方的基础速率。 脚本和工具请创建 API 密钥,并通过 X-API-Key 请求头发送。 在个人资料页创建一个。 密钥按身份而非 IP 归集你的请求(跨网络稳定,绝不与同一 NAT 下的其他用户共享),并提供用量跟踪;其等级上限按端点计算。响应携带 X-RateLimit-Remaining / X-RateLimit-Reset,便于你控制请求节奏。
速率限制
| 网站流量 | 300/minute | 每个 IP |
| 无 API 密钥 | 15/minute | |
| 注册用户 | 60/minute | 在个人资料中创建 |
| 学术 | 100/minute | 按申请授予 |
| 付费 | 120/minute | 赞助者 |
所有上限按端点计算:表格是你在每条路由上的配额,而不是全局池。少数重型端点有自己的预算,无论是否使用密钥都对所有调用者生效(见下方的对局导出;语言 ZIP 为每小时 10 次)。关注 X-RateLimit-Remaining,遇到 429 时退避(会设置 Retry-After)。
批量导出对局
GET /api/exports/runs?limit=1000&start=2026-06-01T00:00:00Z以 JSONL 流式输出官方对局,每行一局。
limit 限制页面大小;满页会返回指向下一页的 cursor。start / end 限制为半开区间的提交时间窗口。分页时保持不变;cursor 不包含它们。该端点有自己的预算,每小时 120 点,带密钥和匿名调用者共享:分页请求消耗 1 点,无限制拉取(不带 limit)消耗 60 点。因此持续同步最好用间隔约 30 秒的分页拉取;遇到 429 时遵守 Retry-After,并用同一个 cursor 继续。
需要完整数据?不带参数的调用会重定向到每天重建一次的静态文件 /exports/runs-latest.jsonl.gz,行格式相同;/api/exports/runs/manifest 给出生成时间和对局数量。每行包含 player_token,即提交账户的稳定化名 ID,匿名对局为 null。
只要某个补丁?/api/exports/runs?version=v0.111.0 会重定向到 manifest 的 versions 表中对应版本的静态文件 /exports/runs-v0.111.0.jsonl.gz;配合 limit 和 cursor 则改为对单个补丁分页拉取。
基础 URL
https://spire-codex.comBeta 频道(来自 Steam beta 分支的未发布内容):在任意实体端点上加上: ?channel=beta. 当前 beta 版本: /api/beta/version. 与 main 的完整差异: /api/beta/diff.
The community stats pages were reorganized: /community-stats, /leaderboards/metrics, /charts, and the /meta page now live under /stats, /leaderboards/elo is /top-players, and run submission moved to /runs/submit. Old URLs redirect.
端点
完整交互式文档(由后端自动生成,始终最新): /docs
实体
聚合与查询
Languages
社区与提交
批量下载
多语言
在任意端点上加上此查询参数: ?lang=jpn. 支持 17 种语言:
eng, ara, deu, esp, fra, ind, ita, jpn, kor, pol, ptb, rus, spa, tha, tur, zhs, zht
快速开始
cURL
curl https://spire-codex.com/api/cards?color=ironclad&rarity=RarePython
import requests
cards = requests.get("https://spire-codex.com/api/cards", params={"color": "ironclad"}).json()
for card in cards:
print(f"{card['name']} - {card['type']} ({card['rarity']})")JavaScript
const res = await fetch("https://spire-codex.com/api/relics?pool=ironclad");
const relics = await res.json();
console.log(relics.map(r => r.name));迷你卡牌精灵图
在任何网页项目中复现游戏内的卡牌缩略图(用于对局历史 / 游戏结束界面)。六层 PNG 通过 CSS mask-image 合成,不用 canvas,不用 WebGL,只是上色的精灵图。 颜色直接取自反编译的游戏代码: NTinyCard, CardPoolModel.DeckEntryCardColor.
预览



Ironclad / Attack / Common


Silent / Skill / Uncommon


Defect / Power / Rare


Necrobinder / Skill / Rare


Regent / Attack / Uncommon


Fool / Attack / Rare


Curse


Event


Quest精灵图资源
全部 10 个 PNG 均启用 CORS,把基础 URL 放在每个文件名前即可。每个精灵图为 128×128、RGBA、透明底白色(用于通过 CSS 上色)。
https://spire-codex.com/static/images/ui/run_history_card/
card_back.png ← tinted by pool
desc_box.png ← dark description area (render at 25% opacity)
attack_portrait.png ← portrait per card type
attack_portrait_shadow.png
skill_portrait.png
skill_portrait_shadow.png
power_portrait.png
power_portrait_shadow.png
banner_shadow.png ← render at 60% opacity
banner.png ← tinted by rarity卡池(卡背)颜色
来源: CardPoolModel.DeckEntryCardColor. 将它们与 /api/cards 返回的 color 字段对应。
稀有度(横幅)颜色
来源: NTinyCard.GetBannerColor. 与 rarity 字段对应。
最简 HTML + CSS 示例
肖像文件名: attack = 攻击牌, power = 能力牌, skill = 其余所有(技能、状态、诅咒……)
<div class="tiny-card" style="
--back: #D62000; /* pool color, Ironclad */
--banner: #FFDA36; /* rarity color, Rare */
position: relative;
width: 64px;
height: 64px;
">
<!-- 1. card back, tinted by pool -->
<div class="layer" style="
background-color: var(--back);
mask: url(https://spire-codex.com/static/images/ui/run_history_card/card_back.png) center/contain no-repeat;
-webkit-mask: url(https://spire-codex.com/static/images/ui/run_history_card/card_back.png) center/contain no-repeat;
"></div>
<!-- 2. description box -->
<img class="layer" src="https://spire-codex.com/static/images/ui/run_history_card/desc_box.png" style="opacity:.25">
<!-- 3. portrait shadow + portrait (attack/skill/power) -->
<img class="layer" src="https://spire-codex.com/static/images/ui/run_history_card/attack_portrait_shadow.png">
<img class="layer" src="https://spire-codex.com/static/images/ui/run_history_card/attack_portrait.png"
style="filter: brightness(.95) sepia(.15)">
<!-- 4. banner shadow + banner tinted by rarity -->
<img class="layer" src="https://spire-codex.com/static/images/ui/run_history_card/banner_shadow.png" style="opacity:.6">
<div class="layer" style="
background-color: var(--banner);
mask: url(https://spire-codex.com/static/images/ui/run_history_card/banner.png) center/contain no-repeat;
-webkit-mask: url(https://spire-codex.com/static/images/ui/run_history_card/banner.png) center/contain no-repeat;
"></div>
</div>
<style>
.tiny-card .layer {
position: absolute; inset: 0;
width: 100%; height: 100%;
object-fit: contain;
}
</style>React 组件
开箱即用的 React 版本。源码: TinyCard.tsx
import TinyCard from "./TinyCard";
// Feed in the three fields from /api/cards:
<TinyCard color="ironclad" type="Attack" rarity="Rare" className="w-16 h-16" />完整卡牌图片
/api/cards 返回的每张卡牌都包含两个可直接使用的 URL,指向游戏渲染的完整卡牌(边框、插画、横幅和文字,与游戏内完全一致)。远古者卡牌为动态 webp。
image_url_card— 基础卡。唯一一张没有渲染图的卡(mad_science)为 null;此时请回退到 image_url(肖像插画)。image_url_card_upg— 升级卡。卡牌没有升级时为 null。
// e.g. /api/cards/bash
{
"id": "BASH",
"image_url": "/static/images/cards/bash.webp", // portrait art
"image_url_card": "https://cdn.spire-codex.com/cards-full/stable/bash.webp",
"image_url_card_upg": "https://cdn.spire-codex.com/cards-full/stable/bash_upg.webp"
}本地化渲染图位于语言子文件夹下,例如: cards-full/stable/jpn/bash.webp. 全部 15 种语言均可用。
拼合附魔卡牌
预渲染的附魔卡牌图片不再更新。附魔卡牌就是在基础卡牌图片上叠加一个徽章,因此可以用三个公开文件拼合:
image_url_card / image_url_card_upg // base card, 400x520, from /api/cards
https://cdn.spire-codex.com/card-render/enchant_tab.png // badge frame
https://cdn.spire-codex.com/enchantments/{id}.webp // icon, lowercase id from /api/enchantments<div class="ench-card">
<img class="base" src="https://cdn.spire-codex.com/cards-full/stable/bash.webp">
<img class="tab" src="https://cdn.spire-codex.com/card-render/enchant_tab.png">
<img class="icon" src="https://cdn.spire-codex.com/enchantments/sharp.webp">
<!-- only Adroit, Momentum, Nimble, Sharp, Swift and Vigorous show an amount -->
<span class="amount">3</span>
</div>
<style>
.ench-card { position: relative; width: 400px; aspect-ratio: 400 / 520; container-type: inline-size; }
.ench-card img { position: absolute; }
.ench-card .base { inset: 0; width: 100%; }
.ench-card .tab { left: 11.1%; top: 22.1%; width: 17.8%; }
.ench-card .icon { left: 14.5%; top: 23.8%; width: 8.75%; }
.ench-card .amount {
position: absolute; left: 22.25%; top: 27.9%; transform: translateX(-50%);
font: 700 4.25cqw/1 Kreon, serif; color: #fff6e2;
-webkit-text-stroke: 1cqw #090f1c; paint-order: stroke fill;
}
</style>- 带星辰费用的卡牌上徽章位置更低:边框用 top 30.8%,图标用 32.5%,数值用 36.6%。
- 部分附魔还会给卡牌增加一行文字(/api/enchantments 的 extra_card_text)。图片上没有位置添加,所以请显示在卡牌旁边,或者用开源的 React 卡牌绘制整张卡牌,它会把文字排到正确位置: CardRender.tsx
数据导出
将全部游戏数据下载为单个 ZIP 压缩包。每个压缩包包含所有实体类型(卡牌、遗物、怪物、能力等)的 JSON 文件。
交互式 API 文档
完整的 Swagger/OpenAPI 文档,支持在线试用。
打开 API 文档 →开源
Spire Codex 是开源的。数据提取流水线、API 和前端都可以在 GitHub 上获取。
在 GitHub 上查看 →