Package Exports
- startgg.js
- startgg.js/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (startgg.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
startgg.js
Node.js SDK for the public Start.gg API, which is rich with data about tournament brackets that have occurred on their platform.
require('colors');
const startgg = require('startgg.js');
const {Event} = startgg;
startgg.initialize('<your api key>');
(async function(){
let tournamentSlug = 'function-1-recursion-regional';
let eventSlug = 'melee-singles';
let meleeAtFunction = await Event.get(tournamentSlug, eventSlug);
let sets = await meleeAtFunction.getSets();
let phaseGroups = await meleeAtFunction.getPhaseGroups();
console.log('Function 1 had %s sets played in %s phase groups',
sets.length, phaseGroups.length);
console.log('Set Results:')
for(var i in sets){
console.log(`${String(sets[i].getFullRoundText()).magenta}: ${String(sets[i].getDisplayScore()).green}`);
}
return true; // exit async
})()Results:

Repo Owner: Ricardo Maury
- Twitter: RickoModeStar
Base Code Author: Brandon Cooke
- Codebase: Github
Installation
npm install --save startgg.jsIssues
- Please submit any issues or feature requests to the Issues Section of the Github
Contents
Getting Started
To begin coding with the SDK, you need an Access Token. You may get one by Joining the Smash.gg discord and asking Furtive for an API key.
Once you have this key, you may use the following function to authenticate with the API and then you may move on
// import the SDK
const startgg = require('startgg.js');
// authenticate with key
startgg.initialize('<your api key here>');Limitations
Currently, startgg.js is limited by start.gg's rate limiting rules. Those are currently
80 requests per 60 seconds. That is, every request made to the API starts a 60 second timer.
If 80 requests are made before the first 60 second timer is completed, your next request will
be dropped.
This SDK implements a Queueing system when your code becomes "Delinquent", that is it has made too many requests too fast. Your requests won't be dropped, but rather will wait until the next available request slot opens.
If you wish to see this queuing info, it is recommended you maintain the "info" logging level (See Logging).
Access to V1-V3
These versions have not been updated from the base code repo. You may use these if you wish but they may be deleted soon.
The original API has no Sunset date set currently. While this is the case, I thought it best to make the original SDK available to people so that they may maintain their apps while beginning to move into V4. You may access v1-v3 SDK as follows:
let smashggV1 = require('smashgg.js/src/v1');Logging
Winston
You can access the built in Winston logger by using the following methods
const startgg = require('startgg.js');
let log = startgg.Log;
log.info('Here\'s some text')
log.debug('Don\'t print this here')
startgg.setLogLevel('debug')
log.info('Print everything now!!')
log.verbose('Not to be verbose...')
log.debug('but i\'m trying to debug :)')
startgg.setLogLevel('warn');You can also add a Logger of your own, say if you'd like a File logger added
const startgg = require('startgg.js')
let log = startgg.Log
startgg.addLog('file', {
filename: '/tmp/log',
level: 'verbose',
format: winston.format.combin(
winston.format.splat(),
winston.format.simple()
)
})The following are the operations at your disposal
setLogLevel(level)
- level: string
- Valid values are
- error
- warn
- info
- verbose
- debug
- Valid values are
- level: string
addLog(type, options)
- type: string
- valid values:
- console
- file
- valid values:
- options: winston.LoggerOptions
- if you need this, please see this link
- type: string
disableLog()
- disabled the embedded logger
enableLog()
- enables the embedded logger