ts-torn-api is a TypeScript wrapper for using the Torn API.
Using npm:
$ npm install ts-torn-apiimport{TornAPI}from'ts-torn-api';constmyKey='ADD_YOUR_KEY_HERE';consttorn=newTornAPI(myKey);constmyBattleStats=awaittorn.user.battlestats();// check for errorif(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