Torn API Client
    Preparing search index...

    Class TornAPI

    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();

    The TornAPI constructor accepts the following options:

    Option Type Default Description
    apiKeys string[] Required An array of one or more Torn API keys
    rateLimitMode 'autoDelay' │ 'throwOnLimit' │ 'ignore' 'autoDelay' How to handle the 100 requests/minute limit
    apiKeyBalancing 'roundRobin' │ 'random' 'roundRobin' Strategy for distributing requests across multiple keys
    comment string undefined A comment to include in the comment query parameter for your requests
    headers Record<string, string> {} Custom headers to send with each request
    verbose boolean false If true, logs all outgoing requests, responses, and rate limit events

    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

    If a page does not exist, these methods return null

    • autoDelay (Default): Automatically queues requests to ensure you do not exceed the 100 req/min limit
    • throwOnLimit: Throws a TornRateLimitError if a request would exceed the limit
    • ignore: Disables rate limiting. Not recommended unless you have your own external limiter
    Index

    Constructors

    Properties

    rateLimitMode: RateLimitMode

    Methods

    • Returns real-time rate limit information for each API key and values contain usage details

      Returns Record<string, { remaining: number; resetInMs: number; used: number }>