Skip to content

jgolla/torn-api

Repository files navigation

ts-torn-api

ts-torn-api is a TypeScript wrapper for using the Torn API.

Installing

Using npm:

$ npm install ts-torn-api

Using

import { TornAPI } from 'ts-torn-api';

const myKey = 'ADD_YOUR_KEY_HERE';
const torn = new TornAPI(myKey);
const myBattleStats = await torn.user.battlestats();

// check for error
if (TornAPI.isError(myBattleStats)) {
    console.log(`${myBattleStats.code}: ${myBattleStats.error}`);
} else {
    console.log(`strength: ${myBattleStats.strength}`);
    console.log(`speed: ${myBattleStats.speed}`);
}

Building

  1. Clone this repo, git clone https://github.com/jgolla/torn-api
  2. Install the dependencies, npm install
  3. Build the library, npm run build

Importing TornOpenAPI types

  1. Download https://www.torn.com/swagger/openapi.json locally to the main directory
  2. Run npm run gentypes

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published