Skip to content

Getting Started

JamesxX edited this page Apr 19, 2022 · 3 revisions

to be completed soon

Adding TRAW to your project

To add the library to your project, as with all node modules, simply call the following command in your terminal:

npm install --save traw

Getting a TRAW instance up and ready

Simply, getting a TRAW instance is as simple as instantiating it through the constructor, with a valid requestor class. Here is an example below, taken directly from one of the TRAW unit tests:

import {traw, passwordGrantRequestor, userAgent} from 'traw'
import variables from "../../mochavariables.json"

let instance : traw = new traw(new passwordGrantRequestor({
    userAgent: new userAgent(
        variables.credentials.useragent.platform,
        variables.credentials.useragent.API,
        variables.credentials.useragent.version,
        variables.credentials.useragent.user
    ),
    username: variables.credentials.login.username,
    password: variables.credentials.login.password,
    client_id: variables.credentials.client.id,
    client_secret: variables.credentials.client.secret
}))

That's it! You don't need to do any more calls, TRAW will internally make sure that you are always logged in. There are different requestors available, which you will choose based on the type of app you are making (e.g., a script, a mobile app, a website, etc.).

Clone this wiki locally