Package Exports
- smashgg.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 (smashgg.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
smashgg.js
Node.js SDK for the public Smash.gg API, which is rich with data about tournament brackets that have occurred on their platform.
require('colors');
const smashgg = require('smashgg.js');
const {Event} = smashgg;
smashgg.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:

Author: Brandon Cooke
- Organization: RecursionGG
- Email: BrandonCookeDev@gmail.com
- Discord: cookiE#7679
Installation
npm install --save smashgg.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 smashgg = require('smashgg.js');
// authenticate with key
smashgg.initialize('<your api key here>');Limitations
Currently, smashgg.js is limited by Smash.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
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 smashgg = require('smashgg.js');
let log = smashgg.Log;
log.info('Here\'s some text')
log.debug('Don\'t print this here')
smashgg.setLogLevel('debug')
log.info('Print everything now!!')
log.verbose('Not to be verbose...')
log.debug('but i\'m trying to debug :)')
smashgg.setLogLevel('warn');You can also add a Logger of your own, say if you'd like a File logger added
const smashgg = require('smashgg.js')
let log = smashgg.Log
smashgg.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
Docs
Tournament
A Tournament in smash.gg is a collection of Events, Phases, and Phases Groups that categorize different games played, game types within those games, and the matches that make up those games.
const smashgg = require('smashgg.js');
const Tournament = smashgg.Tournament;
(async function(){
let ceo2016 = await Tournament.getTournament('ceo2016');
console.log(ceo2016.getName());
let ceoEvents = await Tournament.getEvents();
let phases = await Tournament.getPhases();
let phaseGroups = await Tournament.getPhaseGroups();
})();Constructor
Tournament(
id: number,
name: string,
slug: string,
startTime: Date | null,
endTime: Date | null,
timezone: string | null,
venue: Venue,
organizer: Organizer
)Properties
- id
- number
- id number of the tournament
- name
- string
- name of the tournament
- slug
- string
- url slug of the tournament
- startTime
- Date | null
- start time unix epoch of the tournament
- endTime
- Date | null
- end time unix epoch of the tournament
- timezone
- string | null
- timezone of the location of the tournament
- venue
- Venue
- contains information about the Venue (see Venue docs)
- organizer
- Organizer
- contains information about the Organizer (see Organizer docs)
Statics
async get(slug)
- get a tournament object
- parameters
- slug
- string
- shorthand or tournament slug-name in smashgg
- ceo-2016 or function-1-recursion-regional
- shorthand: to12 instead of tipped-off-12-presented-by-the-lab-gaming-center
- slug
- returns Promise
async getById(id)
- get a tournament object
- parameters
- id
- number
- numeric identifier of the tournament
- id
- returns Promise
async searchAttendees(smashtag)
- get a list of Attendees that contain the given smashtag in their gamertag
- parameters
- smashtag
- string
- the smashtag you are searching for, or a subset of characters from it
- smashtag
- returns a Promise resolving a List of Attendee objects, or null if no match
async searchAttendeesBySponsorTag(sponsorTag)
- get a list of Attendees that contain the given sponsor tag in their profile
- parameters
- sponsorTag
- string
- the sponsor tag you are searching for, or a subset of characters from it
- sponsorTag
- returns a Promise resolving a List of Attendee objects, or null if no match
Methods
getId()
- gets the id property of the tournament
- returns number
getName()
- gets the name property of the tournament
- returns string
getSlug()
- gets the slug property of the tournament
- returns string
getTimezone()
- gets the timezone property of the tournament
- returns string | null
getStartTime()
- gets the start time property of the tournament in JS Date object
- returns Date | null
getStartTimeString()
- gets the start time property of the tournament in Date string
- returns string | null
getEndTime()
- gets the end time property of the tournament in JS Date object
- returns Date | null
getEndTimeString()
- gets the end time property of the tournament in Date string
- returns string | null
getVenue()
- gets the Venue object where this tournament takes place
- returns Venue
getVenueName()
- gets the venue name where this tournament takes place
- returns string | null
getCity()
- gets the city string where this tournament takes place
- returns string | null
getState()
- gets the state string where this tournament takes place
- returns string | null
getAddress()
- gets the address string where this tournament takes place
- returns string | null
getZipCode()
- gets the zip code string where this tournament takes place
- returns string | null
getOrganizer()
- gets the Organizer object who organized this tournament
- returns Organizer
getContactInfo()
- gets the contact info of the organizer
- returns string | null
getContactEmail()
- gets the email string of the organizer
- returns string | null
getContactTwitter()
- gets the twitter handle string of the organizer
- returns string | null
getOwnerId()
- get the numeric id of the owner's player profile
- returns number | null
getEvents()
- aggregates all of the Event objects belonging to the tournament
- return Promise<Event[]>
getPhases()
- aggregates all the Phase objects belonging to the tournament
- return Promise<Phase[]>
getPhaseGroups()
- aggregates all the PhaseGroup objects belonging to the tournament
- return Promise<PhaseGroup[]>
Venue
A Venue is the location of a tournament, and encapsulates data about that location.
let venue = new Venue('Buckhead Theater', '3110 Roswell Rd NE, Atlanta, GA 30305', 'Atlanta', 'GA', '1', 'United States', '30305', 33.8403, 84.3796);
console.log(venue.getName()); // prints "Buckhead Theater"
console.log(venue.getCity()); // prints "Atlanta"Constructor
Venue(
name: string | null,
address: string | null,
city: string | null,
state: string | null,
postalCode: string | null,
countryCode: string | null,
region: string | null,
latitude: number | null,
longitude: number | null
);Properties
- venueName
- string | null
- venueAddress
- string | null
- city
- string | null
- addrState
- string | null
- countryCode
- string | null
- region
- string | null
- postalCode
- string | null
- lat
- number | null
- lng
- number | null
Getters
- getName()
- get the name string of the venue
- string | null
- getAddress()
- get the address of the venue
- string | null
- getCity()
- get the city string of the venue
- string | null
- getState()
- get the state string of the venue
- string | null
- getPostalCode()
- get the postal code string of the venue
- string | null
- getCountryCode()
- get the country code string of the venue
- string | null
- getRegion()
- get the country region of the venue
- string | null
- getLatitude()
- get the numeric latitude of the venue
- number | null
- getLongitude()
- get the numeric longitude of the venue
- number | null
Organizer
An Organizer is an individual or organization in Smash.gg that organizes a tournament and is the owner of a Tournament's webpage in smash.gg
let org = new Organizer(7000, 'info@recursion.gg', '123-456-7890', '@recursiongg', 'This is where info goes lul');
console.log(org.getName());
console.log(org.getTwitter());Constructor
Organizer(
id: number | null,
email: string | null,
phone: string | null,
twitter: string | null,
info: string | null
);Getters
- getId()
- gets the numeric id of the organizer
- number | null
- getEmail()
- gets the email string of the organizer
- string | null
- getPhone()
- gets the phone number string of the organizer
- string | null
- getTwitter()
- gets the twitter handle string of the organizer
- string | null
- getInfo()
- gets the information string of the organizer
- string | null
Event
An Event in smash.gg is a broad collection of matches for a single game and game type. For instance, Melee Singles is an Event while Melee Doubles is another Event. Events are comprised of optional Phases and Phases Groups.
const smashgg = require('smashgg.js');
const Event = smashgg.Event;
(async function(){
let meleeSinglesAtEvo = await Event.get('evo-2017', 'melee-singles');
let meleeDoublesAtFunction1 = await Event.get('function-1-recursion-regional', 'melee-doubles');
let sfvAtEvo = await Event.getById(21726);
let wiiUAtEvo = await Event.getBySlug('tournament/evo-2017/events/super-smash-bros-for-wii-u');
let phaseGroups = await meleeSinglesAtEvo.getPhaseGroups();
let sets = sfvAtEvo.getSets();
})();Constructor
Event(
id: number ,
name: string,
slug: string,
state: string | null,
startAt: number | null,
numEntrants: number | null,
checkInBuffer: number | null,
checkInDuration: number | null,
checkInEnabled: boolean | null,
isOnline: boolean | null,
teamNameAllowed: boolean | null,
teamManagementDeadline: number | null
)Properties
- id
- number
- name
- string
- slug
- string
- state
- string | null
- startAt
- number | null
- numEntrants
- number | null
- checkInBuffer
- number | null
- checkInDuration
- number | null
- checkInEnabled
- boolean | null
- isOnline
- boolean | null
- teamNameAllowed
- boolean | null
- teamManagementDeadline
- number | null
Statics
async get(tournamentSlug, eventSlug)
- get an event by tournament and event names
- parameters
- tournamentSlug
- string
- NOTE this is not eligable for shorthand
- smashgg url slug of the tournament
- eventSlug
- string
- smashgg url slug of the event
- tournamentSlug
- returns Promise
async getBySlug(slug)
- get an event by the full slug path
- parameters
- slug
- string
- tournament + event all-in-one slug
- ie. tournament/ceo-2017/event/melee-singles
- slug
- returns Promise
async getById(id)
- get an event by the numeric id
- parameters
- id
- number
- numeric id of the event
- id
- returns Promise
Methods
- getId()
- gets the numeric identifier for the event
- returns number
- getName()
- gets the name string for the event
- returns string
- getSlug()
- gets the name url slug for the event
- returns string
- getState()
- gets the state string of the event
- this is the current state of the event
- eg: 'COMPLETED'
- returns string | null
- getNumEntrants()
- gets the number of tournament attendees who entered this event
- returns number | null
- getCheckInBuffer()
- gets the amount of time before check in begins
- returns number | null
- getCheckInDuration()
- gets the amount of time check in will last
- returns number | null
- getCheckInEnabled()
- gets the true/false value for if event is doing check-in
- returns boolean | null
- getIsOnline()
- gets the true/false value for if the event is Online
- returns boolean | null
- getTeamNameAllowed()
- gets the true/false value for if the event allows team names
- returns boolean | null
- getTeamManagementDeadline()
- gets the true/false value for if the event has a team management deadline
- returns number | null
Aggregations
- getPhases()
- gets the Phase objects owned by this Event
- returns Promise<Phase[]>
- getPhaseGroups()
- gets the Phase Group that occurred in this event
- returns Promise<PhaseGroup[]>
- getEntrants(options: IEntrant.EntrantOptions)
- gets the tournament attendees who competed in this event
- parameters
- options
- EntrantOptions
- series of options for the return set of Entrants
- options
- returns Promise<Entrant[]>
- getAttendees(options: IAttendee.AttendeeOptions)
- gets the tournament attendees who are in this event
- parameters
- options
- AttendeeOptions
- series of options for the return set of Attendees
- options
- returns Promise<Attendee[]>
- getSets(options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this event
- parameters
- options
- SetOptions
- series of options for the return set of GGSets
- options
- returns Promise<GGSet[]>
- getIncompleteSets(options: IGGSet.SetOptions)
- gets the tournament sets in this event that have yet to be completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSets
- options
- returns Promise<GGSet[]>
- getCompleteSets(options: IGGSet.SetOptions)
- gets the tournament sets in this event that have been completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSets
- options
- returns Promise<GGSet[]>
- getSetsXMinutesBack(minutesBack: number, options: IGGSet.SetOptions)
- gets the tournament sets in this event that were completed x minutes ago
- parameters
- minutesBack
- number
- how many minutes ago do you want to search for completed sets
- options
- SetOptions
- series of options for the return set of GGSets
- minutesBack
- returns Promise<GGSet[]>
Phase
A phase in smash.gg is a subset of matches and brackets inside an Event. For example, a wave in pools is a Phase. Everything in that Phase is a Group (or Phase Group).
const smashgg = require('smashgg.js');
const Phase = smashgg.Phase;
(async function(){
let phase1 = await Phase.get(111483);
console.log(phase1.getName()); // prints "Pools"
console.log(phase1.getNumSeeds()); // prints 156
let entrants = await phase1.getEntrants();
})()Constructor
Phase(
id: number,
name: string,
eventId: number,
numSeeds: number,
groupCount: number
)Properties
- id
- number
- name
- string
- eventId
- number
- numSeeds
- number
- groupCount
- number
Statics
- async get(id)
- get a phase by numeric id
- parameters
- id
- number
- numeric id of the phase
- id
Methods
getId()
- gets the numeric identifier of this phase
- returns number
getEventId()
- gets the numeric identifier of the event which owns this phase
- returns number
getName()
- gets the name string of the phase
- returns string
getNumSeeds()
- gets the number of seeds that are in this phase
- returns number
getGroupCount()
- gets the number of phase groups belonging to this phase
- returns number
getPhaseGroups()
- gets the phase groups belonging to this phase
- returns: Promise<PhaseGroup[]>
getEntrants(options: IEntrant.EntrantOptions)
- gets the tournament attendees who competed in this phase
- parameters
- options
- EntrantOptions
- series of options for the return set of Entrants
- options
- returns Promise<Entrant[]>
getSets(options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this phase
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getIncompleteSets(options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this phase which are not completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getCompleteSets(options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this phase which are completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getSetsXMinutesBack(minutesBack: number, options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this phase which were completed x minutes ago
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
PhaseGroup
A Phase Group is the lowest unit on smash.gg. It is a bracket of some sort that belongs to a Phase.
const smashgg = require('smashgg.js');
const PhaseGroup = smashgg.PhaseGroup;
let phaseGroup1 = await PhaseGroup.get(44445);Constructor
PhaseGroup(
id: number,
phaseId: number,
displayIdentifier: string | null,
firstRoundTime: number | null,
state: number | null,
waveId: number | null,
tiebreakOrder: object | null
)Properties
- id
- number
- phaseId
- number
- displayIdentifier
- string | null
- firstRoundTime
- number | null
- state
- number | null
- waveId
- number | null
- tiebreakOrder
- object | null
Statics
- async get(id)
- get a phase group by numeric id
- parameters
- id
- number
- numeric id of the phase group
- id
Methods
getId()
- gets the numeric identifier of the phase group
- returns number
getPhaseId()
- gets the numeric identifier of the phase groups owning phase
- returns number
getDisplayIdentifier()
- gets the display identifier string of the phase group
- returns string | null
getFirstRoundTime()
- get the time of the first round of the phase group as a unix epoch
- returns number | null
getState()
- get the numeric state of the the phase group
- returns number | null
getWaveId()
- get the numeric wave id of the phase group
- returns number | null
getTiebreakOrder()
- get the JSON tiebreaker order of the phase group
- returns object | null
getSeeds(options: ISeed.SeedOptions)
- gets the seeds in this phase group
- parameters
- options
- SeedOptions
- series of options for the return set of Seeds
- options
- returns Promise<Seed[]>
getEntrants(options: IEntrant.EntrantOptions)
- gets the tournament attendees who competed in this phase group
- parameters
- options
- EntrantOptions
- series of options for the return set of Entrants
- options
- returns Promise<Entrant[]>
getAttendees(options: IAttendee.AttendeeOptions)
- gets the tournament attendees who were in this phase group
- parameters
- options
- AttendeeOptions
- series of options for the return set of Attendees
- options
- returns Promise<Attendee[]>
getSets(options: IGGSet.SetOptions)
- gets the tournament sets that occurred in this phase group
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getCompleteSets(options: IGGSet.SetOptions)
- get the tournament sets in this phase group that have been completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getIncompleteSets(options: IGGSet.SetOptions)
- get the tournament sets in this phase group that have not been completed
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
getSetsXMinutesBack(minutes: number, options: IGGSet.SetOptions)
- get the tournament sets in this phase group that have been completed within the last x minutes
- parameters
- options
- SetOptions
- series of options for the return set of GGSet
- options
- returns Promise<GGSet[]>
User
A User is a data object that holds information about users on Smash.gg's platform
This is equivalent to the Player object in smash.gg's context.
var user = new User(000000, 'cookiE', 'Brandon Cooke', 'US', 'GA', 'Recursion')
console.log(user.getTag()); // prints 'cookiE'
console.log(user.getState()); // prints 'GA'Constructor
User(
id: number,
gamerTag: string,
prefix: string | null,
color: string | null,
twitchStream: string | null,
twitterHandle: string | null,
youtube: string | null,
region: string | null,
state: string | null,
country: string | null,
gamerTagChangedAt: number | null
)Properties
- id
- number
- gamerTag
- string
- prefix
- string | null
- color
- string | null
- twitchStream
- string | null
- twitterHandle
- string | null
- youtube
- string | null
- region
- string | null
- state
- string | null
- country
- string | null
- gamerTagChangedAt
- number | null
Methods
getId()
- gets the numeric id of the User
- returns number
getGamerTag()
- gets the gamer tag of the User
- returns string
getSponsor()
- get the sponsor prefix of the User
- returns string | null
getColor()
- get the color the User has chosen
- returns string | null
getTwitchStream()
- get the linked twitch channel name of the User
- returns string | null
getTwitterHandle()
- get the linked twitter handle of the User
- returns string | null
getYoutube()
- get the linked youtube channel of the User
- returns string | null
getRegion()
- get the region the User is from
- returns string | null
getState()
- get the state the User is from
- returns string | null
getCountry()
- get the country the User is from
- returns string | null
getGamerTagChangedAt()
- get the last time the User changed their gamer tag as a JS Date object
- returns Date | null
getRecentSets()
- get a list of the recent GGSets the User has competed in
- return Promise<GGSet[]>
getRankings()
- get a list of the rankings the User has achieved.
- return Promise<PlayerRank[]>
Attendee
An Attendee is a person who attendeed a tournament.
This is equivalent to Participant in Smash.gg's context.
Constructor
Attendee(
id: number,
gamerTag: string,
prefix: string | null,
createdAt: number | null,
claimed: boolean | null,
verified: boolean | null,
playerId: number | null,
phoneNumber: number | null,
connectedAccounts: object | null,
contactInfo: IAttendee.ContactInfo | null,
eventIds: number[] | null
)Properties
- id
- number
- gamerTag
- string
- prefix
- string | null
- createdAt
- number | null
- claimed
- boolean | null
- verified
- boolean | null
- playerId
- number | null
- phoneNumber
- number | null
- connectedAccounts
- object | null
- contactInfo
- IAttendee.ContactInfo | null
- eventIds
- number[] | null
Methods
- getId()
- get the numeric id for the Attendee in the tournament
- returns number
- getGamerTag()
- get the gamer tag of the Attendee
- returns string
- getSponsor()
- get the sponsor prefix of the Attendee
- returns string | null
- getCreatedAt()
- get the unix epoch of when this Attendee was created
- returns number | null
- getClaimed()
- get the true/false value of if this Attendee is claimed by a user
- returns boolean | null
- getVerified()
- get the true/false value of if this Attendee is verified
- returns boolean | null
- getPlayerId()
- get the numeric identifier of the associated User object
- returns number | null
- getPhoneNumber()
- get the phone number of the Attendee
- returns number | null
- getContactInfo()
- get the contact info of the Attendee
- returns ContactInfo | null
- getCity()
- get the city the Attendee is from
- returns string | null
- getState()
- get the state the Attendee is from
- returns string | null
- getStateId()
- get the numeric id of the state the Attendee is from
- returns number | null
- getCountry()
- get the country the Attendee is from
- returns string | null
- getCountryId()
- get the numeric id of the country the Attendee is from
- returns number | null
- getContactName()
- get the contact name of the Attendee
- returns string | null
- getFirstName()
- get the first name of the Attendee
- returns string | null
- getLastName()
- get the last name of the Attendee
- returns string | null
- getZipcode()
- get the zip code of the Attendee
- returns string | null
getConnectedAccounts() * get a list of connected accounts to this Attendee * returns object | null <<<<<<< HEAD
- async getUserAccount()
- async getEnteredPhases()
- get list of Phases that this Attendee entered
- returns Promise resolving a list of Phase objects
- async getEnteredPhaseGroups()
- get list of Phase Groups that this Attendee entered
- returns Promise resolving a list of PhaseGroup objects
de14b38cdac89a9e2aafe013f548910a403f9519
AttendeeOptions
{
page?: number | null,
perPage?: number | null,
sortBy?: string | null,
filter?: null | {
id?: number,
entrantName?: string,
checkInState?: number,
phaseGroupId?: number[],
phaseId?: number[],
eventId?: number,
seach?:{
fieldsToSearch: string[],
searchString: string
}
}
}Entrant
An Entrant is an Attendee who entered and competed in an Event.
This is the same as Entrant in Smash.gg's context
Constructor
Entrant(
id: number,
name: string,
eventId: number,
skill: number,
attendeeData: Attendee[]
)Properties
- id
- number,
- name
- string,
- eventId
- number,
- skill
- number,
- attendeeData
- Attendee[]
Methods
getId()
- get the numeric id of the Entrant
- returns number
getName()
- get the name of the Entrant
- returns string
getEventId()
- get the numeric identifier of the Event the Entrant is in
- returns number
getSkill()
- get the skill level of the Entrant
- returns number
getAttendeeData(position: number)
getAttendeeId(position: number)
getGamerTag(position: number)
getSponsor(position: number)
getPhoneNumber(position: number)
getContactInfo(position: number)
getCity(position: number)
getState(position: number)
getStateId(position: number)
getCountry(position: number)
getCountryId(position: number)
getName(position: number)
getFirstName(position: number)
getLastName(position: number)
getZipcode(position: number)
- get the zip code of the Attendee connected to the Entrant
- parameters
- position
- number
- the array index of the desired Attendee
- position
- returns string | null
getConnectedAccounts()
- returns object | null
EntrantOptions
{
page?: number | null,
perPage?: number | null,
sortBy?: string | null,
filter?: null | {
id?: number,
entrantName?: string,
checkInState?: number,
phaseGroupId?: number[],
phaseId?: number[],
eventId?: number,
seach?:{
fieldsToSearch: string[],
searchString: string
}
}
}GGSet
A Set is a data object that holds information about a tournament set that took place at a tournament.
Constructor
GGSet(
id: number,
eventId: number | null,
phaseGroupId: number | null,
displayScore: string | null,
fullRoundText: string | null,
round: number | null,
startedAt: number | null,
completedAt: number | null,
winnerId: number | null,
totalGames: number | null,
state: number | null,
player1: PlayerLite,
player2: PlayerLite,
score1: number | null,
score2: number | null
)Properties
- id
- number
- eventId
- number | null
- phaseGroupId
- number | null
- displayScore
- string | null
- fullRoundText
- string | null
- round
- number | null
- startedAt
- number | null
- completedAt
- number | null
- winnerId
- number | null
- totalGames
- number | null
- state
- number | null
- player1
- player2
- score1
- number | null
- score2
- number | null
Methods
- getEventId()
- get the numeric identifier of the GGSet
- returns number | null
- getPhaseGroupId()
- get the numeric identifier of the Phase the GGSet belongs to
- returns number | null
- getStartedAt()
- get the time the GGSet started as a JS Date object
- returns Date | null
- getCompletedAt()
- get the time the GGSet ended as a JS Date object
- returns Date | null
- getDisplayScore()
- get the display score string of the GGSet
- format "Tag1 Score1 - Score2 Tag2"
- returns string | null
- getFullRoundText()
- get the full round text of the tournament this GGSet takes place
- returns string | null
- getRound()
- get the numeric round of the tournament this GGSet takes place
- returns number | null
- getState()
- get the numeric state of the GGSet
- returns number | null
- getPlayer1()
- get the first player in the GGSet
- returns PlayerLite | undefined | null
- getPlayer1Tag()
- get the first player's tag in the GGSet
- returns string | undefined | null
- getPlayer1PlayerId()
- get the first player's User ID in the GGSet
- returns number | undefined | null
- getPlayer1AttendeeIds()
- get the first player's Attendee ID in the GGSet
- returns number[] | undefined | null
- getPlayer2()
- get the second player in the GGSet
- returns PlayerLite | undefined | null
- getPlayer2Tag()
- get the second player's tag in the GGSet
- returns string | undefined | null
- getPlayer2PlayerId()
- get the second player's User ID in the GGSet
- returns number | undefined | null
- getPlayer2AttendeeIds()
- get the second player's Attendee ID In the GGSet
- returns number[] | undefined | null
- getWinnerId()
- get the Entrant ID of the winning player
- returns number | null
- getLoserId()
- get the Entrant ID of the losing player
- returns number | null
- getIsComplete()
- get the true/false value for if this GGSet has been completed
- returns boolean | null
- getPlayer1Score()
- get the score of the first player in the GGSet
- returns number | null
- getPlayer2Score()
- get the score of the second player in the GGSet
- returns number | null
- getWinner()
- get the winner of the GGSet
- returns PlayerLite | undefined
- getLoser()
- get the loser of the GGSet
- returns PlayerLite | undefined
- getBestOfCount()
- get the Best-Of count of the GGSet
- returns number | string
- getWinnerScore()
- get the score of the winner in the GGSet
- returns number | string
- getLoserScore()
- get the score of the loser in the GGSet
- returns number | string
SetOptions
{
filterDQs?: boolean,
filterByes?: boolean,
filterResets?: boolean,
page?: number | null,
perPage?: number | null,
sortBy?: null | 'NONE' | 'STANDARD' | 'RACE_SPECTATOR' | 'ADMIN',
filters?: null | {
entrantIds?: number[],
state?: number[],
stationIds?: number[],
phaseIds?: number[],
phaseGroupIds?: number[],
roundNumber?: number
}
}PlayerLite
{
tag: string | null,
entrantId: number | null,
attendeeIds: number[]
}Stream
A Stream is a live stream of a Tournament
Constructor
Stream(
id: number,
eventId: number | null,
tournamentId: number | null,
streamName: string,
numSetups: number | null,
streamSource: 'TWITCH' | 'HITBOX' | 'STREAMME' | 'MIXER' | null,
streamType: number | null,
streamTypeId: number | null,
isOnline: boolean | null,
enabled: boolean | null,
followerCount: number | null,
removesTasks: boolean | null,
streamStatus: string | null,
streamGame: string | null,
streamLogo: string | null
)Properties
- id
- number
- eventId
- number | null
- tournamentId
- number | null
- streamName
- string
- numSetups
- number | null
- streamSource
- 'TWITCH' | 'HITBOX' | 'STREAMME' | 'MIXER' | null
- streamType
- number | null
- streamTypeId
- number | null
- isOnline
- boolean | null
- enabled
- boolean | null
- followerCount
- number | null
- removesTasks
- boolean | null
- streamStatus
- string | null
- streamGame
- string | null
- streamLogo
- string | null
Methods
- getId()
- get the numeric ID of the Stream
- number,
- getEventId()
- get the ID of the Event this Stream occurred in
- number | null,
- getTournamentId()
- get the ID of the Tournament this Stream occurred in
- number | null,
- getStreamName()
- get the name of the Stream
- string,
- getNumSetups()
- get the number of setups
- number | null,
- getStreamSource()
- get the source of the Stream
- 'TWITCH' | 'HITBOX' | 'STREAMME' | 'MIXER' | null,
- getStreamType()
- get the type of the Stream
- number | null,
- getStreamTypeId()
- get the numeric type of the Stream
- number | null,
- getIsOnline()
- get the true/false value for if the Stream is online
- boolean | null,
- getEnabled()
- get the true/false value of if the Stream is enabled
- boolean | null,
- getFollowerCount()
- get the follower count the Stream has
- number | null,
- getRemovesTasks()
- get the true/false value of if this Stream removes tasks
- boolean | null,
- getStreamStatus()
- get the status of the Stream
- string | null,
- getStreamGame()
- get the game the Stream is streaming
- string | null,
- getStreamLogo()
- get the url of the Stream's logo
- string | null
StreamQueue
A StreamQueue is a Queue of GGSets that are in line to be played on a Stream
Constructor
StreamQueue(
stream: Stream,
sets: GGSet[]
)Properties
Methods
- getStream()
- getSets()
Seed
Constructor
Seed(
id: number,
entrantId: number,
placeholderName: string,
seedNumber: number,
placement: number,
isBye: boolean
)Properties
- id
- number
- entrantId
- number
- placeholderName
- string
- seedNumber
- number
- placement
- number
- isBye
- boolean
SeedOptions
{
page?: number | null,
perPage?: number | null,
sortBy?: string | null,
filter?: null | {
id?: number
entrantName?: string
checkInState?: number
phaseGroupId?: number[]
phaseId?: number[]
eventId?: number
search?: {
fieldsToSearch: string[]
searchString: string
}
}
}Character
A Character object encapsulates data about a fighting game character in the smashgg system
let meleeCharacters = await Character.getByGameName('melee')
let pmCharacters = await Character.getByGameId(2)
let allBowsers = await Character.getByName('bowser')
allBowsers.forEach(bowser => {
console.log(bowser)
})
let allCharacters = await Character.getAll({isCached: false})
allCharacters.forEach(character => {
console.log(character)
})
let meleeBowser = await Character.getByNameAndGame('bowser', 'melee')
let wolfPM = await Character.getByNameAndGameId('wolf', 2)Constructor
- Character(id, name, isCommon, videogameId)
- id - ID number of the character in the smashgg system
- name - Name of the character
- isCommon - T/F value for if the character is a common one
- videogameId - ID of the SmashGG VideoGame this character belongs to
Methods
Promises
- static async getAll([options])
- Returns a Promise resolving an array of
Characterobjects representing all characters in SmashGG - options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving an array of
- static async getById(id [, options])
- Returns a Promise resolving a
Characterobject representing the character in SmashGG with the given id - id - [required] ID number of the character in SmashGG's system
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving a
- static async getByName(name [, options])
- Returns a Promise resolving an Array of
Characterobjects representing the character in SmashGG that match the given name - name - [required] Name of the desired character in SmashGG's system
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving an Array of
- static async getByGameId(id [, options])
- Returns a Promise resolving an Array of
Characterobjects representing all the characters from the given Smashgg videogame Id - id - [required] Id of the SmashGG VideoGame which to fetch all characters from
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving an Array of
- static async getByGameName(name [, options])
- Returns a Promise resolving an Array of
Characterobjects representing all the characters from the given Smashgg videogame name/slug/displayname - name - [required] Display Name/short name/nickname of the game in SmashGG's system
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving an Array of
- static async getByNameAndGameId(name, videogameId [, options])
- Returns a Promise resolving a
Characterobject from the SmashGG Character name and the VideoGame ID - name - [required] Name of the character in SmashGG's system
- videogameId - [required] ID number of the videogame in SmashGG's system
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving a
- static async getByNameAndGame(name, gameName [, options])
- Returns a Promise resolving a
Characterobject from the SmashGG Character name and the Videogame name - name - [required] Name of the character in SmashGG"s system
- gameName - [required] Display name/name/slug of the SmashGG video game
- options - object containing options for the function
- isCached - boolean value for if the results should be fetched/put into cache. Default is true
- Returns a Promise resolving a
Getters
- getId() - returns the SmashGG Character ID
- getName() - returns the Name of the character
- getIsCommon() - returns the T/F isCommon value of the character
- getVideoGameId() - return the SmashGG VideoGame ID that the character belongs to
VideoGame
A VideoGame object encapsulates data about VideoGames respective to how they are known in Smash GG's system
let melee = await VideoGame.getByName('melee')
/* produces:
{ id:1,
name:'Super Smash Bros. Melee',
abbrev:'Melee',
displayName:'Melee',
minPerEntry:1,
maxPerEntry:2,
approved:true,
slug:'melee',
isCardGame:null
}
*/
let pm = await VideoGame.getById(2)
/* produces:
{
id:2,
name:'Project M',
abbrev:'pm',
displayName:'PM',
minPerEntry:null,
maxPerEntry:null,
approved:true,
slug:'pm',
isCardGame:null
}
*/
let allGames = await VideoGame.getAll()
/* produces array of all VideoGame objects in SmashGG */Constructor
- VideoGame(id, name, abbrev, displayName, minPerEntry, maxPerEntry, approved, slug, isCardGame)
- id - id number of the game
- name - full name of the game
- abbrev - abbreviated name of the game
- displayName - display name of the game on smashgg's site
- minPerEntry - minimum number of entrants that can sign up
- maxPerEntry - maximum number of entrants that can sign up
- eg: Melee is 2 because of doubles, two individuals can sign up at once
- approved - boolean if the game has been approved in smashgg's system
- slug - the game's url slug
- isCardGame - boolean for if the game is a card game
Methods
Statics
static async getAll([options])
- Returns an array of VideoGame objects representing every game in smashgg's system
- options - optional options object
- isCached - boolean for if the value should be cached/pulled from cache
static async getByName(name [,options])
- Returns a VideoGame object representing the video game belonging to the given name
- This value will match the games
name,abbrev,displayName, andslugproperties
- This value will match the games
- name - [required] - name, abbrev, displayName, or slug of the desired game
- options - optional options object
- isCached - boolean for if the value should be cached/pulled from cache
- Returns a VideoGame object representing the video game belonging to the given name
static async getById(id [,options])
- Returns a VideoGame object representing the video game belonging to the given id
- id - [required] - id of the desired game
- options - optional options object
- isCached - boolean for if the value should be cached/pulled from cache
Getters
- getId()
- return the id of the Video Game
- getName()
- return the full name of the Video Game
- getAbbreviation()
- return the abbreviation of the Video Game
- getDisplayName()
- return the smashgg display name of the Video Game
- getMinPerEntry()
- return the minimum number of participants for an entry of the Video Game
- getMaxPerEntry()
- return the maximum number of participants for an entry of the Video Game
- getApproved()
- return the boolean value of if the Video Game has been approved for smashgg
- getSlug()
- return the url slug of the Video Game
- getIsCardGame()
- return the boolean value of if the Video Game is a card game
Upgrading
This section is for detailing the transition between major versions.
V3 to V4
Easily the largest change that has occurred in the lifespan of this SDK. Please read carefully to successfully upgrade versions.
- All major objects (
Tournament,Event,Phase,PhaseGroup) have refactored the main getter renamed toget()Tournament.getTournament(slug)==>Tournament.get(slug)Event.getEvent(eventName, tournamentName)==>Event.get(tournamentName, eventName)Phase.getPhase(id)==>Phase.get(id)PhaseGroup.getPhaseGroup(id)==>PhaseGroup.get(id)
Eventno longer acceptsTournamentslug shorthand- shorthand like "function1" need to be refactored to their full slug version like "function-1-recursion-regional"
Tournamentno longer has aggregate functions likegetAllSets()orgetAllPlayers()- due to the limitations, the SDK can no longer support aggregate functions for Tournament objects,
I recommend using individual
Eventobjects to accomplish your goals
- due to the limitations, the SDK can no longer support aggregate functions for Tournament objects,
I recommend using individual
- Take caution in doing aggregate functions on
Eventsof very large size, like Evo Melee or something similar. You could find yourself hitting the rate limit very easily.
Maintaining V1-V3
As described in Access V1-V3, you may use the original SDK while it has not been Sunset. See that section for more details.
V2 to V3
In order to transition successfully from V2 to V3, please ensure the following
All Set objects created by smashgg.js are renamed to GGSet
V1 to V2
In order to transition successfully from V1 to V2, please ensure the following
- Event constructors now take eventId parameter before tournamentId parameter.
- Additionally, you can give the constructor an Id number for the event, and null tournamentId.
Tournament,Event,Phase, andPhaseGroupconstructors now take anoptionsobject that encapsulates the previousisCachedandexpandsparameters.- Please see documentation for further implementation.
- It is suggested you move to the Promise returning convenience methods, as the previous
readyevent will be deprecated from this point on.- Please see documentation for the convenience methods. They take the same parameters as the constructor.