Main class
Provides access to all API sections
const client = new TornAPI({ apiKeys: ["YOUR_API_KEY1", "YOUR_API_KEY2"], comment: "my-app", rateLimitMode: "autoDelay", verbose: true,});const userProfile = await client.user.withId(12345).get(); Copy
const client = new TornAPI({ apiKeys: ["YOUR_API_KEY1", "YOUR_API_KEY2"], comment: "my-app", rateLimitMode: "autoDelay", verbose: true,});const userProfile = await client.user.withId(12345).get();
The TornAPI constructor accepts the following options:
TornAPI
apiKeys
string[]
rateLimitMode
'autoDelay' │ 'throwOnLimit' │ 'ignore'
'autoDelay'
apiKeyBalancing
'roundRobin' │ 'random'
'roundRobin'
comment
string
undefined
headers
Record<string, string>
{}
verbose
boolean
false
true
The client is organized by API categories:
client.user
client.faction
client.market
client.property
client.racing
client.forum
client.key
client.torn
Endpoints that return lists are paginated
The response object is a special PaginatedResponse class that always includes .next() and .prev() methods to easily fetch adjacent pages
PaginatedResponse
.next()
.prev()
If a page does not exist, these methods return null
null
autoDelay
throwOnLimit
TornRateLimitError
ignore
Creates an instance of the TornAPI client
Configuration options for the client
Readonly
Returns real-time rate limit information for each API key and values contain usage details
Main class
Provides access to all API sections
Example
Configuration
The
TornAPIconstructor accepts the following options:apiKeysstring[]rateLimitMode'autoDelay' │ 'throwOnLimit' │ 'ignore''autoDelay'apiKeyBalancing'roundRobin' │ 'random''roundRobin'commentstringundefinedcommentquery parameter for your requestsheadersRecord<string, string>{}verbosebooleanfalsetrue, logs all outgoing requests, responses, and rate limit eventsCore Concepts
API Endpoints
The client is organized by API categories:
client.userclient.factionclient.marketclient.propertyclient.racingclient.forumclient.keyclient.tornPagination
Endpoints that return lists are paginated
The response object is a special
PaginatedResponseclass that always includes.next()and.prev()methods to easily fetch adjacent pagesIf a page does not exist, these methods return
nullRate Limiting
autoDelay(Default): Automatically queues requests to ensure you do not exceed the 100 req/min limitthrowOnLimit: Throws aTornRateLimitErrorif a request would exceed the limitignore: Disables rate limiting. Not recommended unless you have your own external limiter