Install
The SDK runs in Node 22 or newer and in browsers. Catalogs and formulas need no setup; account imports accept only official game JSON exports. Optional wiki and Sheets integrations use network access. These docs cover the published SDK version 3.5.4.
npm install @beardedunicorn/thetowersdk@3.5.4 --save-exactBuild From Source
For SDK development, build from source instead of installing from npm. Build the SDK, pack it, and install the generated tarball in your application. Record the source commit for reproducibility.
git clone https://github.com/BeardedUnicorn/TheTowerSDK.git
cd TheTowerSDK
pnpm install
pnpm build
npm pack
# Run in your application directory:
npm install /path/to/TheTowerSDK/beardedunicorn-thetowersdk-3.5.4.tgzPinning A Version
Game numbers change when the game does. Install an exact version when you want them frozen, and upgrade deliberately after a patch.
npm install @beardedunicorn/thetowersdk@3.5.4 --save-exactWhat A Version Means
The package follows semantic versioning. Data values change when the game does, which is why the line above pins an exact version rather than a range.
- Patch — fixes and data corrections.
- Minor — new exports, extractors and data, including data updated for a new game version; existing values may change.
- Major — breaking API changes.
The promise covers every entry point; there is no path past them to fall outside it.
Your First Lines
Nothing to initialise — import a catalog and read it.
import { LAB_CATALOG } from '@beardedunicorn/thetowersdk/data'
import { formatNumberForDisplay } from '@beardedunicorn/thetowersdk/formatting'
const lab = LAB_CATALOG.find((entry) => entry.name === 'Attack Speed')
const total = lab.levels.reduce((sum, level) => sum + level.cost, 0)
console.log(lab.levels.length, 'levels')
console.log(formatNumberForDisplay(total), 'coins to max')The Entry Points
Fifteen entry points, imported by name. Nothing is bundled that you do not import, so a tool that only needs catalogs does not carry the save reader.
| Import | What it holds |
|---|---|
@beardedunicorn/thetowersdk/data | Every catalog — labs, workshop, modules, cards, relics, bots, guardians, ultimate weapons, vault, perks, tiers, milestones. Docs |
@beardedunicorn/thetowersdk/mechanics | 1009 formulas — enemy scaling, timing, costs, damage reduction, Effective Paths. Docs |
@beardedunicorn/thetowersdk/builders | Fifteen builders that describe their own inputs. Docs |
@beardedunicorn/thetowersdk/save | Extractors over a decoded save — runs, labs, cards, modules, bots, vault. Docs |
@beardedunicorn/thetowersdk/node | Decoding tool_export.json bytes. Node only. Docs |
@beardedunicorn/thetowersdk/save-decoder | The same save reader with no Node imports, for decoding in a browser tab. Docs |
@beardedunicorn/thetowersdk/contributions | The roster of whose work this package carries, as data you can render. Docs |
@beardedunicorn/thetowersdk/charts | 72 chart datasets, each a finished table. Docs |
@beardedunicorn/thetowersdk/knowledge | The mechanics graph and five years of patch notes. Docs |
@beardedunicorn/thetowersdk/wiki | Community wiki pages as Markdown. Docs |
@beardedunicorn/thetowersdk/sheets | Google Sheets reading and writing, A1 helpers. Docs |
@beardedunicorn/thetowersdk/bot | Every calculator as a chat command. Docs |
@beardedunicorn/thetowersdk/formatting | Numbers, durations, multipliers and rates in the game's own notation — read and written. Docs |
@beardedunicorn/thetowersdk/assets | Naming rules for artwork you supply yourself, so a tool can find a file in a directory of art you already have. |
TypeScript
Types ship with the package, so there is no @types to add. Every catalog and every result
is typed, which means your editor can list a mechanic's stats without you opening the docs.
import type { PatchNote } from '@beardedunicorn/thetowersdk/knowledge'
// Autocomplete knows the fields, and a typo is a compile error.
function summarise(note: PatchNote) {
return `${note.postedAt.slice(0, 10)} ${note.version ?? '—'} ${note.title}`
}In The Browser
Everything except @beardedunicorn/thetowersdk/node runs in a browser bundle. The
package is marked side-effect free, so a bundler drops what you do not use — import the one
catalog you need rather than the whole of data if size matters.
// Reading a save in the browser: decode the bytes from a file input,
// then use the same extractors.
import { listImportableBattleRuns } from '@beardedunicorn/thetowersdk/save'What Else You Might Add
None of these are required. The SDK works on its own.
- The MCP server already ships inside the package — register it and your editor's assistant can query the catalogs while it writes. MCP docs
toweraiif you want an assistant of your own, plus a model key. TowerAI docsadb-bridgeif your tool reads saves from a phone or emulator. Your users run it; it is not a dependency of your project. Save docs