ThunderAPI

ThunderAPI

Provides data from War Thunder

Constructor

new ThunderAPI(optionsopt)

Source:

Creates a new instance of ThunderAPI

Parameters:
Name Type Attributes Default Description
options ThunderAPIOptions <optional>
{}

The timeout in milliseconds to sweep the cache, defaults to 180000 milliseconds

Members

(private) _intervals :Set.<Timeout>

Source:

Intervals set by ThunderAPI#setInterval that are still active

Type:
  • Set.<Timeout>

(private) _timeouts :Set.<Timeout>

Source:

Timeouts set by ThunderAPI#setTimeout that are still active

Type:
  • Set.<Timeout>

(readonly) cacheSweepInterval :number

Source:

The time cache should be sweeped, in milliseconds

Type:
  • number

clans :Collection.<string, Clan>

Source:

A collection of cached squadrons. The collection will be sweeped after the time passed

Type:

(nullable) lastNews :Array.<NewsInfo>

Source:

The cached array of news items

Type:

(private) rest :RequestHandler

Source:

The Request Handler for ThunderApi

Type:
  • RequestHandler

users :Collection.<string, Profile>

Source:

A collection of cached profiles. The collection will be sweeped after the time passed

Type:

Methods

clearInterval(interval)

Source:

Clears an interval.

Parameters:
Name Type Description
interval Timeout

Interval to cancel

clearTimeout(timeout)

Source:

Clears a timeout.

Parameters:
Name Type Description
timeout Timeout

Timeout to cancel

destroy()

Source:

Destroys all assets used by ThunderAPI.

fetchClan(name, cacheopt) → {Promise.<Clan>}

Source:

Get's info about a squadron.

You must provide the full name of the squadron, e.g. "35th Gopnik nation battle group" instead of "GOPNK".
Example
// The following example gets info about
// the squadron 35th Gopnik nation battle group,
// and logs the squadron description, and the
// date this squadron was created
ThunderAPI.getSquadron("35th Gopnik nation battle group")
  .then(data => {
    console.log(data.description);
    console.log(data.createdAt);
  })
  .catch(err => console.error("Oh no, an error occurred!", err));
Parameters:
Name Type Attributes Default Description
name string

The full name of the squadron

cache boolean <optional>
true

If it should get the squadron from the cache, if cached. Defaults to true

Returns:
Type
Promise.<Clan>

fetchUser(player, cacheopt) → {Promise.<User>}

Source:

Get a player's profile

Example
// The following example gets the profile of the player
// TheDutchy0412 and logs the squadron name
// and the registration date
ThunderAPI.getPlayer("TheDutchy0412")
  .then(profile => {
    console.log(profile.squadron);
    console.log(profile.registered);
  })
  .catch(err => console.error("Oh no, an error occurred!", err));
Parameters:
Name Type Attributes Default Description
player string

The profile of the player to fetch

cache boolean <optional>
true

If it should get the player from the cache. Defaults to true

Returns:
Type
Promise.<User>

getNews(cacheopt) → {Promise.<Array.<NewsInfo>>}

Source:

Returns an array of news objects

Parameters:
Name Type Attributes Default Description
cache boolean <optional>
true

If it should return the cached news object. Defaults to true

Returns:
Type
Promise.<Array.<NewsInfo>>

isUser(player) → {Promise.<boolean>}

Source:

Verifies the given player's in-game nickname

Parameters:
Name Type Description
player string

The player to verify

Returns:
Type
Promise.<boolean>

searchWiki(query) → {Promise.<Array.<Wiki>>}

Source:

Searches on the War Thunder wiki

Parameters:
Name Type Description
query string

The query to search on

Returns:
Type
Promise.<Array.<Wiki>>

setInterval(fn, delay, …args) → {Timeout}

Source:

Sets an interval that will be automatically cancelled if the client is destroyed.

Parameters:
Name Type Attributes Description
fn function

Function to execute

delay number

Time to wait between executions (in milliseconds)

args * <repeatable>

Arguments for the function

Returns:
Type
Timeout

setTimeout(fn, delay, …args) → {Timeout}

Source:

Sets a timeout that will be automatically cancelled if the instance of ThunderAPI is destroyed.

Parameters:
Name Type Attributes Description
fn function

Function to execute

delay number

Time to wait before executing (in milliseconds)

args * <repeatable>

Arguments for the function

Returns:
Type
Timeout

sweepCache() → {boolean}

Source:

Sweeps the cache

Returns:

If the cache sweep was successful

Type
boolean