TheTowerSDK
Game data, save-file reading and the game's own formulas for The Tower, as typed TypeScript —
so you can build calculators, planners, spreadsheets, charts and bots without transcribing a single
number by hand.
This is a fork. BeardedUnicorn/TheTowerSDK is
maintained by Mike Herold and published as @beardedunicorn/thetowersdk. It is forked from
TmRxJD/TheTowerSDK, the original work of TmRxJD, whose
package on npm is thetowersdk. See Credits.
npm install @beardedunicorn/thetowersdk
- Game data — labs, workshop, modules, cards, perks, relics, guardians, bots, ultimate weapons
and the vault, with their cost curves and effect values, as typed arrays.
- Save reading — turn a player's
tool_export.json into typed values: what they have researched,
what they own, what is equipped, their run history.
- Formulas — enemy scaling, damage, ultimate weapons, drops and workshop stats, as functions you
call with a tier, a wave or a level.
- Charts — every level progression is already a plot-ready series, so the shipped catalogs cover
909 chartable series, each with an id to fetch it by, without you authoring one.
TypeScript, MIT licensed, one runtime dependency (zod).
Versions. The package follows semantic versioning from 1.0.0 — see Versioning.
Game data changes when the game does, so pin an exact version if you need the numbers frozen.
Quick Start
Use The Game Data
import { LAB_CATALOG } from '@beardedunicorn/thetowersdk/data'
const costToMax = (lab) => lab.levels.reduce((sum, level) => sum + level.cost, 0)
const priciest = LAB_CATALOG
.map((lab) => ({ name: lab.name, total: costToMax(lab) }))
.sort((a, b) => b.total - a.total)[0]
Every cost is a plain number of coins. There is no scaling factor to apply and no currency field
to read first — a lab that costs 1.1 quadrillion is 1.1e15, so you can add two labs together
without checking where either came from.
Read a Save File
import { readFile } from 'node:fs/promises'
import { decodePlayerInfoSaveBytesAsync } from '@beardedunicorn/thetowersdk/node'
import { readLabsFromSaveRoot } from '@beardedunicorn/thetowersdk/save'
const { parsedRoot } = await decodePlayerInfoSaveBytesAsync(await readFile('tool_export.json'))
const labs = readLabsFromSaveRoot(parsedRoot)
if (!labs) throw new Error('This save has no lab research data.')
console.log(`${labs.researchedCount} researched, ${labs.maxedCount} maxed`)
Decode once, then extract whatever you need. Only official JSON exports are supported; private save files are rejected.
Private save files and legacy binary files are unsupported.
Entry Points
| Import |
Contains |
Browser-safe |
@beardedunicorn/thetowersdk/data |
Game tables — costs, levels, effects, catalogs |
Yes |
@beardedunicorn/thetowersdk/save |
read*FromSaveRoot() readers and save inspection |
Yes |
@beardedunicorn/thetowersdk/node |
The save decoder |
Node — see below |
@beardedunicorn/thetowersdk/save-decoder |
The same decoder with no Node imports, for the browser |
Yes |
@beardedunicorn/thetowersdk/formatting |
Number and duration formatting matching the game |
Yes |
@beardedunicorn/thetowersdk/mechanics |
Game formulas — see below |
Yes |
@beardedunicorn/thetowersdk/wiki |
Fandom wikitext → Markdown — see below |
Yes |
@beardedunicorn/thetowersdk/contributions |
Whose work this package carries, as data |
Yes |
@beardedunicorn/thetowersdk/charts |
Curated chart catalog and its data — see below |
Yes |
@beardedunicorn/thetowersdk/builders |
Ready-made calculators — see below |
Yes |
@beardedunicorn/thetowersdk/calculators |
Every exported formula declared by name — what it reads, what it produces, how to call it |
Node |
@beardedunicorn/thetowersdk/bot |
Command registry, and every calculator as a command — see below |
Yes |
@beardedunicorn/thetowersdk/sheets |
Google Sheets reads and writes — see below |
Yes |
@beardedunicorn/thetowersdk/knowledge |
The mechanics oracle, and five years of patch notes — see below |
Yes |
@beardedunicorn/thetowersdk/assets |
Path helpers for artwork you supply — see below |
Yes |
import { … } from '@beardedunicorn/thetowersdk' re-exports data, save and formatting together. Prefer the
subpaths in real projects so your bundler can drop what you don't use.
import { computeWaveBaseHealth, abilityDamage } from '@beardedunicorn/thetowersdk/mechanics'
import { formatDuration } from '@beardedunicorn/thetowersdk/formatting'
How It Fits Together
tool_export.json ──decodePlayerInfoSaveBytesAsync()──► save root (plain object)
│
┌───────────────────────────────┼──────────────────────────────┐
▼ ▼ ▼
readLabsFromSaveRoot() readModulesFromSaveRoot() readVaultFromSaveRoot()
│ │ │
▼ ▼ ▼
typed lab data typed module data typed vault data
The save root is a plain JavaScript object. Extractors read from it and never modify it, so you
can run as many as you like over the same root.
Getting an Official Game Export
First tap your Player ID five times in The Tower to create your first export and reveal the export controls. Then open Settings → Toggles → External Tools Export → Manual Export. Enable Auto Export for External Tools to keep the export updated. Import only tool_export.json.
On Android and emulators the export is in Android/data/com.TechTreeGames.TheTower/files/tool_export.json. Copy it to a folder your browser can access, or use adb-bridge to pull the official export.
On a Mac the game writes it to ~/Library/Containers/<id>/Data/Documents/tool_export.json, where <id> is a UUID that differs per install. findToolExport() from @beardedunicorn/thetowersdk/node scans for it, and the MCP save tools use it when no path is given. Set TOWER_TOOL_EXPORT to the file's path to name it outright on any platform.
Private saves such as playerInfo.dat, encrypted containers and legacy binary save files are unsupported. The SDK accepts no decryption keys and provides no decryption service.
Attempting to bypass save-file encryption violates The Tower Terms of Service.
import { decodeSaveFile } from '@beardedunicorn/thetowersdk/save-decoder'
const root = await decodeSaveFile(await exportFile.arrayBuffer())
Export files contain personal account data. Tell users plainly if your tool uploads them anywhere.
Reading a Save
| Function |
Returns |
readLabsFromSaveRoot |
Research levels, what's maxed, the active queue |
readWorkshopFromSaveRoot |
Upgrade levels, enhancements, saved presets |
readModulesFromSaveRoot |
Owned modules, rarities, substats, equipped |
readCardsFromSaveRoot |
Card levels, copies, mastery, equipped slots |
readGuardiansFromSaveRoot |
Guardian levels and upgrades |
readBotsFromSaveRoot |
Bot levels, Bot+ unlocks, synchronicity slots, medals spent |
readUltimateWeaponsFromSaveRoot |
UW levels, unlocks, plus-levels, stones |
readVaultFromSaveRoot |
Vault power tree progress |
readRelicsFromSaveRoot |
Owned relics |
readCollectedThemeNamesFromSaveRoot |
Unlocked themes |
readLifetimeFromSaveRoot |
Lifetime totals |
readDissonanceCycleWavesFromSaveRoot |
Best wave per tier this dissonance cycle |
listImportableBattleRuns |
Run history |
readSaveSeriesFromSaveRoot |
Runs and tournaments by date, and records by tier, as {x, y} series |
Plus perks, "killed by" and per-run battle report fields — see src/save/index.ts.
Check Before You Read
Extractors return null when a save has no data for that feature, rather than throwing, so older
saves degrade instead of failing:
const labs = readLabsFromSaveRoot(parsedRoot)
if (!labs) return
if (labs.warnings.length) {
// Values the extractor could not interpret. Usually means the save shape changed.
console.warn(labs.warnings)
}
Run History And Battle Reports
Every completed run the game kept is available, with all of its stored fields:
import { listImportableBattleRuns, buildBattleReportStatFields } from '@beardedunicorn/thetowersdk/save'
const runs = listImportableBattleRuns(parsedRoot)
// The raw entry — tier, wave, duration, coins, cells, damage dealt and taken,
// per-source damage breakdowns, what killed you, and everything else the game
// recorded for that run.
console.log(Object.keys(runs[0]))
// Or the same run flattened into named stat fields.
const stats = buildBattleReportStatFields(runs[0])
listImportableBattleRuns hands back the decoded entries themselves, not a filtered view, so you
are not limited to the fields this SDK happens to name. There are also helpers for duration
formatting, date parsing and deduplication — see src/save/index.ts.
Reading Any Field In a Save
parsedRoot is the decoded file as a plain object, so every field the game stores is yours to read
directly. The named extractors are a convenience layer over that same object — reach past them
whenever you want a field they do not name.
Values are loosely typed and arrays arrive in several shapes, so use the readers rather than
hand-parsing:
import { coerceSaveNumber, readSaveBoolean, readSaveIntList } from '@beardedunicorn/thetowersdk/save'
coerceSaveNumber(parsedRoot.someKey) // number | null
readSaveBoolean(parsedRoot.someFlag) // boolean
readSaveIntList(parsedRoot.someList) // number[]
Worked out a field that isn't covered? A PR adding an extractor is very welcome.
Reading The Community Wiki
The Tower's wiki is on Fandom, which serves wikitext rather than anything you can render:
templates, infoboxes, [[File:…]] links and vertical wikitables. This converts it to Markdown.
import { fetchFandomPageAsMarkdown } from '@beardedunicorn/thetowersdk/wiki'
const markdown = await fetchFandomPageAsMarkdown('Cards')
Or the halves separately, if you fetch pages your own way — from a cache, a mirror, or a build step:
import { convertFandomWikitextToMarkdown, resolveFandomFileImages } from '@beardedunicorn/thetowersdk/wiki'
const markdown = convertFandomWikitextToMarkdown(wikitext, { pageTitle: 'Cards' })
A page that does not exist returns 200 OK with a missing marker rather than a 404, so
fetchFandomWikitext throws on it instead of returning an empty page.
The conversion ships here; the wiki's content does not. Wiki text is CC-BY-SA and this package
is MIT, so fetch what you need and honor the wiki's license in whatever you ship. It is a
volunteer-run wiki — cache what you fetch, and space out requests when pulling many pages.
Game 29.1 Data
The catalog includes the four released modules and primary-module labs for game 29.1.
| Module |
Slot / save info index |
Epic → Legendary → Mythic → Ancestral |
| Sentry Protocol |
Armor / 50 |
1 → 2 → 3 → 4 mini orbs per shot |
| Tactical Barrage |
Core / 52 |
14 → 10 → 6 → 2 seconds between Homing Missiles |
| Infinity Threshold |
Generator / 53 |
1,000 → 2,000 → 3,000 → 4,000 extra free-upgrade levels |
| Gilded Sniper |
Cannon / 51 |
10% → 20% → 30% → 40% chance on enemy death |
Sentry Protocol stops orb movement and replaces it with mini-orb firing. Its workshop-orb
interval is 1 / (5 * effectiveOrbSpeed) seconds; Extra Orb card orbs use
0.5 / (cardSpeed + extraOrbSpeedLabBonus). Rarity controls mini-orbs per shot.
Tactical Barrage doubles the lab bonuses to Smart Missile Radius and Amplifier, targets the
highest missile stack, and redirects active Smart Missiles to that target. Gilded Sniper applies
all active coin bonuses on a successful proc even outside their range; catalog values are
probabilities (0.1–0.4). Infinity Threshold affects free upgrades to Damage, Health and Health Regen.
Four Primary Module Bonus labs occupy save indices 253–256, in Cannon, Armor,
Generator, Core order. Each has 30 levels, unlocks at tier 23, wave 500, and starts at
1e20 coins and 1,440,000 seconds (400 hours), before modifiers. Each level improves
the primary module's bonus by 1%; the neutral multiplier of 1 and assist bonuses are unaffected.
import { computeModuleStat, findLabResearchByIndex } from '@beardedunicorn/thetowersdk/data'
import { applyWorkshopOvercapMultiplier } from '@beardedunicorn/thetowersdk/mechanics'
findLabResearchByIndex(253)?.displayName // 'Primary Module Bonus - Cannon'
computeModuleStat({ type: 'cannon', rarityLabel: 'Epic +', level: 92, primaryLabLevel: 30 })
// 2.3, from the unresearched multiplier 2.0
applyWorkshopOvercapMultiplier(100, 7000) // approximately 195.52428085