ts-torn-api
is a TypeScript wrapper for using the Torn API.
Using npm:
$ npm install ts-torn-api
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}`);
}
- Clone this repo,
git clone https://github.com/jgolla/torn-api
- Install the dependencies,
npm install
- Build the library,
npm run build
- Download https://www.torn.com/swagger/openapi.json locally to the main directory
- Run
npm run gentypes