donato / torn-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

License:MIT License


Languages

Language:TypeScript 99.9%Language:Shell 0.1%