Torn API fundamentals
What the Torn API is, how keys and access levels work, selections, rate limits and error codes.
Introduction
The Torn API is Torn's official, read-only way for players and tools to fetch game data with an API key. Faction tools, browser extensions, stat trackers and the Academy's own price snapshots all use it. You do not need to understand it to play, but knowing how keys and access levels work helps you decide which tools to trust.
How it works
Read-only. The API only reads information. It cannot send money, attack, revive, trade or take any other action in the game. A tool that claims to do those things for you through the API is wrong, or is doing something else.
Keys. You create keys in your settings. Each key is 16 characters. You can hold up to 25 keys, each with its own access level, and delete any of them at any time. A key identifies you by itself, so a tool never needs your name, ID or password.
Access levels. Every key has one of four levels: Public Only, Minimal Access, Limited Access or Full Access. Higher levels expose more of your private data. The official API documentation lists exactly what each level can read.
Selections. A request asks for a section (for example user, faction or torn) and one or more selections within it. Torn's current API, version 2, is described in an OpenAPI specification that lists every path and the access level it needs.
Rate limits. Each user can make up to 100 requests per minute across all their keys. Too many requests get a key blocked briefly (error 5), and repeated invalid keys can get an IP address blocked (error 8).
Common errors:
| Code | Meaning |
|---|---|
| 2 | Incorrect key |
| 5 | Too many requests |
| 7 | The data is private to someone else |
| 10 | The key owner is in Federal Jail |
| 13 | The key is disabled after 7 days of owner inactivity |
The wiki lists codes 0 to 15. Torn's API documentation is the place to check for any newer codes.
Rules. Torn logs all requests. Tool makers must keep keys and data confidential, request as little data as needed, and must never ask for passwords. Torn can ban misbehaving applications, keys and users.
Step by step
- Open the API key section of your settings.
- Create a new key for each tool, named after the tool.
- Choose the lowest access level the tool says it needs.
- Paste the key only into the tool's own setup page, never into a public chat.
- Delete the key when you stop using the tool.
Examples
- A faction verification tool needs only a Public or Minimal key to confirm who you are.
- A tool that tracks your gym gains needs to read your battle stats, which requires a higher level; that is a reason to check who runs it.
Advanced tips
- One key per tool means you can cut off one tool without affecting the others.
- Keys of inactive players stop working after 7 days, so tools must handle error 13.
Common mistakes
- Using one Full Access key everywhere.
- Thinking the API can perform actions. It is read-only.
- Sharing a key in a public channel, where anyone can copy it.
Was this guide helpful?
Only the total of yes and no answers for each guide is kept. Nothing about you is stored.