Typescript wrapper for the Torn.com API.
npm install ts-torn-apits-torn-api is a TypeScript wrapper for using the Torn API.
bash
$ npm install ts-torn-api
`
Using
`ts
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
1. Install the dependencies, npm install
1. Build the library, npm run build
Importing TornOpenAPI types
1. Download https://www.torn.com/swagger/openapi.json locally to the main directory
1. Run npm run gentypes`