npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-gsa-client

v1.0.17

Published

A Node.js client for the GameServerApp API

Downloads

51

Readme

GSA Client

A Node.js client for the GameServerApp API. Includes full type support. Ported from https://github.com/gameserverapp/PHP-API-Wrapper

Installation

To install the package, use npm:

npm install node-gsa-client

Or with yarn:

yarn add node-gsa-client

Usage

First, import the GSAClient class and create an instance with your Client ID and Client Secret. You can find those items on your Dashboard's API page: https://dash.gameserverapp.com/configure/api

import GSAClient from 'node-gsa-client'

const clientId = 'your-client-id'
const secret = 'your-client-secret'
const client = new GSAClient(clientId, secret)

Error Handling

The client throws GSAClientException for any errors encountered during the request. You can catch these errors and handle them appropriately:

try {
  const settings = await client.domainSettings()
  console.log(settings)
} catch (error) {
  if (error instanceof GSAClientException) {
    console.error(`Error: ${error.message} (Status: ${error.statusCode})`)
  } else {
    console.error(error)
  }
}

Methods

domainSettings

Fetch the domain settings.

const settings = await client.domainSettings()
console.log(settings)

domainStat(type: string = 'hours-played')

Fetch domain statistics. options:

  • hours-played (graph)
  • online-players (graph)
  • new-characters (graph)
  • online-count-last-7-days (graph)
  • hours-played-last-7-days (graph)
  • new-players-last-7-days (graph)
  • active-tribes (group objects)
  • newbies (character objects)
  • top-players (character objects)
  • last-online (character object)
const stats = await client.domainStat('hours-played')
console.log(stats)

clusterStat(uuid: string, type: string = 'online-count-last-7-days')

Fetch cluster statistics. options:

  • online-count-last-7-days (graph)
  • hours-played-last-7-days (graph)
  • new-players-last-7-days (graph)
  • active-tribes (group objects)
  • newbies (character objects)
  • top-players (character objects)
  • last-online (character object)
const uuid = 'your-cluster-uuid'
const stats = await client.clusterStat(uuid, 'online-count-last-7-days')
console.log(stats)

serverStat(id: string, type: string = 'online-count-last-7-days')

Fetch server statistics. options:

  • online-count-last-7-days (graph)
  • hours-played-last-7-days (graph)
  • new-players-last-7-days (graph)
  • active-tribes (group objects)
  • newbies (character objects)
  • top-players (character objects)
  • last-online (character object)
const id = 'your-server-id'
const stats = await client.serverStat(id, 'online-count-last-7-days')
console.log(stats)

servers

Fetch the list of servers.

const servers = await client.servers()
console.log(servers)

group(uuid: string)

Fetch group information.

const uuid = 'your-group-uuid'
const group = await client.group(uuid)
console.log(group)

groupStat(uuid: string, type: string = 'hours-played')

Fetch group statistics. options:

  • hours-played
  • levels-gained
  • xp-gained
const uuid = 'your-group-uuid'
const stats = await client.groupStat(uuid, 'hours-played')
console.log(stats)

groupLog(uuid: string)

Fetch group logs. Requires OAuth login.

const uuid = 'your-group-uuid'
const logs = await client.groupLog(uuid)
console.log(logs)

groupSettings(uuid: string, motd: string, about: string)

Update group settings. Requires OAuth login.

const uuid = 'your-group-uuid'
const motd = 'Message of the day'
const about = 'About the group'
const response = await client.groupSettings(uuid, motd, about)
console.log(response)

groups

Fetch the list of groups.

const groups = await client.groups()
console.log(groups)

user(uuid: string)

Fetch user information.

const uuid = 'your-user-uuid'
const user = await client.user(uuid)
console.log(user)

userStat(uuid: string, type: string = 'hours-played')

Fetch user statistics. options:

  • hours-played
  • levels-gained
  • xp-gained
const uuid = 'your-user-uuid'
const stats = await client.userStat(uuid, 'hours-played')
console.log(stats)

users

Fetch the list of users.

const users = await client.users()
console.log(users)

character(uuid: string)

Fetch character information.

const uuid = 'your-character-uuid'
const character = await client.character(uuid)
console.log(character)

characterStat(uuid: string, type: string = 'hours-played')

Fetch character statistics. options:

  • hours-played
  • levels-gained
  • xp-gained
const uuid = 'your-character-uuid'
const stats = await client.characterStat(uuid, 'hours-played')
console.log(stats)

characters

Fetch the list of characters.

const characters = await client.characters()
console.log(characters)

topCharacters

Fetch the top characters.

const characters = await client.topCharacters()
console.log(characters)

freshCharacters

Fetch the fresh characters.

const characters = await client.freshCharacters()
console.log(characters)

onlineCharacters

Fetch the online characters.

const characters = await client.onlineCharacters()
console.log(characters)

spotlightCharacters

Fetch the spotlight characters.

const characters = await client.spotlightCharacters()
console.log(characters)

shopItems(query: string)

Fetch shop items.

const shopPacks = await client.shopItems() // returns a broad list of shop packs. Mostly collections and top level items.
// OR
const shopPacks = await client.shopItems('dinos') // returns a list of shop packs that match the query string
console.log(shopPacks)

shopItem(id: string)

Fetch a shop item by it's id.

const shopPack = await client.shopItem('6fd21cfb-441e-4a43-824c-451ad0768318')
console.log(shopPack)

License

This project is licensed under the MIT License. See the LICENSE file for details.