2.8.2 • Published 11 months ago

@nethergames/api v2.8.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@nethergames/api

Fully typed client for the NetherGames API. This package requires ESM.

Install

npm install @nethergames/api

Usage

import {NetherGamesClient} from '@nethergames/api'

const ng = new NetherGamesClient(process.env.NG_API_KEY)
const player = await ng.players.retrieve('Hampus3770')
const guild = await ng.guilds.retrieve(player.guild)

API

new NetherGamesClient(apiKey?, options?)

Returns a new instance.

options

Type: object

baseUrl

Type: string\ Default: https://api.ngmc.co

API host to use when sending requests.

cacheMaxSize

Type: number\ Default: 1000

The maximum amount of LRU objects to hold in memory.

userAgent

Type: string\ Default: NetherGames-API-Client/2.8.2

User-agent to use when sending requests.

userAgentAppendix

Optional\ Type: string

Append an identifier to the user agent in parentheses.\ A unique identifier allows us to identify requests in our error monitoring tools.\ Example: Casper's Discord Bot => NetherGames-API-Client/2.8.2 (Casper's Discord Bot)

Instance

All resource methods return a Promise, so you must await them.

.announcements

Returns an AnnouncementsResource.

.factions

Returns a FactionsResource.

.guilds

Returns a GuildsResource.

.leaderboard

Returns a LeaderboardResource.

.players

Returns a PlayersResource.

.search

Returns a SearchResource.

.servers

Returns a ServersResource.

.status

Returns a StatusResource.

.stream

Returns a StreamResource.

.updates

Returns an UpdatesResource.

.lastBuildId

Type: string\ Default: null

The build ID returned from the previous request.

.lastRateLimit

Type: object\ Default: null

The rate limit returned from the previous request.

.lastServerMeta

Type: object\ Default: null

Stores the last retrieved server metadata object. Useful for caching at startup.

.on(event, callback)

Event emitter for error, request, and response. Useful for debugging.

Announcements

.list(type, limit?) Docs

List announcements for a specified type and an optional limit.

Factions

.retrieve(faction, params?) Docs

Retrieve a faction by name or null if not found.

.search(faction[], params?) Docs

Find many (1-100) factions at once.

.list(params?) Docs

A paginated list of factions.

.check(faction) Docs

Check if the specified faction name or ID exists.

Guilds

.retrieve(guild, params?) Docs

Retrieve a guild by name, or null if not found.

.search(guild[], params?) Docs

Find many (1-100) guilds at once.

.list(params?) Docs

A paginated list of guilds.

.check(guild) Docs

Check if the specified guild name or ID exists.

Leaderboard

.list(type, params?) Docs

Return the leaderboard for a specified type with optional params.

.bulk(query[]) Docs

Find many (1-100) leaderboards at once.

Players

.retrieve(player, params?) Docs

Retrieve a player by name or null if not found.

.search(player[], params?) Docs

Find many (1-100) players at once.

.list(params?) Docs

A paginated list of players.

.leaderboard(player, params?) Docs

Retrieve a player leaderboard, or null if not found.

.leaderboardBulk(player[], params?) Docs

Find many (1-100) player leaderboards at once.

.stats(player, type) Docs

Retrieve a player's stats for a specified type.

.statsHistory(player, params?) Docs

Retrieve hourly player stats history. API key required to request new players.

.statsHistoryBulk(players, params?) Docs

Retrieve hourly player stats history in bulk. API key required to request new players.

.xuidMapping(xuidOrUsername[]) Docs

Get a key-value mapping of XUIDs to usernames or vice versa.

.punishments(player) Docs

Retrieve a player's punishments.

.check(player) Docs

Check if a player by the specified username or XUID exists.

Search

.simple(name) Docs

Performs a "simple" search, returning exact matches for player, guild, and faction.

.fulltext(query, params?) Docs

Performs a "fulltext" search, returning partial name matches for the query for all types.

Servers

.retrieve() Docs

Retrieve server statistics.

.meta() Docs

Retrieve server metadata.

.ping(ip = 'play.nethergames.org', port = 19132) Docs

Retrieve server data for any *.nethergames.org IP or null if not found.

.playerCount() Docs

Retrieve the total player count (cached for one hour).

Status

.retrieve() Docs

Retrieve service status.

Stream

.retrieve() Docs

Retrieve YouTube streaming status.

Updates

.list(params?) Docs

List server updates.

2.8.1

11 months ago

2.8.0

12 months ago

2.7.0

12 months ago

2.8.2

11 months ago

2.6.8

1 year ago

2.6.7

1 year ago

2.6.6

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

2.6.3

1 year ago

2.6.2

1 year ago

2.6.5

1 year ago

2.6.4

1 year ago

2.5.6

2 years ago

2.5.5

2 years ago

2.5.8

2 years ago

2.5.7

2 years ago

2.5.9

2 years ago

2.5.10

2 years ago

2.5.11

1 year ago

2.5.12

1 year ago

2.5.13

1 year ago

2.5.4

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.4.2

2 years ago

2.3.7

2 years ago

2.3.0

2 years ago

2.5.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.5.2

2 years ago

2.3.4

2 years ago

2.5.1

2 years ago

2.3.3

2 years ago

2.3.6

2 years ago

2.5.3

2 years ago

2.3.5

2 years ago

2.2.0

2 years ago

2.2.15

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.13

2 years ago

2.2.5

2 years ago

2.0.7

2 years ago

2.2.14

2 years ago

2.2.4

2 years ago

2.0.6

2 years ago

2.2.11

2 years ago

2.2.7

2 years ago

2.0.9

2 years ago

2.2.12

2 years ago

2.2.6

2 years ago

2.0.8

2 years ago

2.2.10

2 years ago

2.1.9

2 years ago

2.1.2

2 years ago

2.0.15

2 years ago

2.1.1

2 years ago

2.0.16

2 years ago

2.1.4

2 years ago

2.0.13

2 years ago

2.1.3

2 years ago

2.0.14

2 years ago

2.1.6

2 years ago

2.0.11

2 years ago

2.1.5

2 years ago

2.0.12

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.0.10

2 years ago

2.1.0

2 years ago

2.2.9

2 years ago

2.2.8

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.20

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago