Package: smashggpy
smashggpysmashggpyis an SDK that wraps around the public smash.gg GraphQL API.
It implements a series of easy to use objects, and features a background thread which
manages outstanding queries to handle GraphQL's Rate Limiting feature.AuthorBrandon Cooke (brandoncookedev@gmail.com)Getting StartedDocsTournamentEventPhasePhaseGroupGGSetPlayerEntrantAttendeeStreamGetting Startedfromsmashggpy.models.EventimportEventfromsmashggpy.utilimportInitializerfromsmashggpy.util.QueryQueueDaemonimportQueryQueueDaemonif__name__=='__main__':Initializer.initialize('API_KEY','info')to12_melee=Event.get('tipped-off-12-presented-by-the-lab-gaming-center','melee-singles')sets=to12_melee.get_sets()forggsetinsets:print("{0}:{1}{2}-{3}{4}".format(ggset.full_round_text,ggset.player1,ggset.score1,ggset.score2,ggset.player2))QueryQueueDaemon.kill_daemon()This results in the following:Winners Final: MVG FOX | Mew2King 2 - 0 OeS | NIX
Losers Semi-Final: Gas$ 0 - 2 bobby big ballz
Winners Semi-Final: MVG FOX | Mew2King 2 - 0 Gas$
Winners Semi-Final: OeS | NIX 2 - 0 bobby big ballz
Losers Quarter-Final: bobby big ballz 2 - 0 DarkGenex
Losers Quarter-Final: Gas$ 2 - 0 Cynax
Losers Round 3: Greenmario 1 - 2 Cynax
Losers Round 3: DarkGenex 2 - 0 CV | Cloud-9
....DocsInitializerMethodsinitialize(api_key [, log_level])initialize the SDKparametersapi_keystringthe api key to access the smash.gg APIoptional: log_levelstringlog level for the built-in loggerallowed values:'critical''error''warning''info''debug'QueryQueueDaemonMethodskill_daemon()ends the parallel thread that is monitoring the QueryQueueNOTEcall this if you need your program to terminate, otherwise ignoreTournamentPropertiesidintid of the tournament objectnamestringname of the tournamentslugstringurl slug of the tournamentstart_timeintunix epoch of the tournament start timeend_timeintunix epoch of the tournament end timetimezonestringtimezone the tournament took place invenueVenueorganizerOrganizerMethodsStaticget(tournament_slug)get tournament data from smashgg for the corresponding tournament slugparameterstournament_slugstringlong-name slug for a tournamentfunction-3-recursion-seriestipped-off-12-presented-by-the-lab-gaming-centerceo-2016returnsTournamentparse(data)parse smash.gg api data into a Tournament objectparametersdatajsonhttp response data from a smash.gg api callreturnsTournamentget_events()get all the events for a given tournamentreturnsEvent[]get_phases()get all the phases for a given tournamentreturnsPhase[]get_phase_groups()get all the phase groups for a given tournamentreturnsPhaseGroup[]get_attendees()get all the attendees for a given tournamentreturnsAttendee[]get_entrants()get all the entrants for a given tournamentreturnsEntrant[]get_sets()get all of the sets played for a given tournamentreturnsGGSet[]get_incomplete_sets()get all of the incomplete sets for a given tournamentreturnsGGSet[]get_completed_sets()get all of the completed sets for a given tournamentreturnsGGSet[]Instanceget_id()get the id property of the tournamentreturns intget_name()get the name property of the tournamentreturns stringget_slug()get the slug property of the tournamentreturns stringget_start_time()get the start_time property of the tournamentreturns intget_end_time()get the end_time property of the tournamentreturns intget_timezone()get the timezone property of the tournamentreturns stringget_venue()get the venue property of the tournamentreturnsVenueget_organizer()get the organizer property of the tournamentreturnsOrganizerEventPropertiesidintthe numeric id of the eventnamestringthe name of the eventslugstringthe url slug of the eventstatestringthe progress of the eventpossible values:CREATEDACTIVECOMPLETEDREADYINVALIDCALLEDQUEUEDstart_atintunix epoch of the start time of the eventnum_entrantsintnumber of entrants in the eventcheck_in_bufferintseconds of how long before the event start will the check-in endcheck_in_durationintseconds of how long the check-in will lastcheck_in_enabledboolt/f of whether this event uses check-inis_onlineboolt/f of whether this event is onlineteam_name_allowedboolt/f of whether this event allows team namesteam_management_deadlineintunix epoch of when team management is no longer allowedMethodsStaticsget(tournament_slug, event_slug)get an Event object for the corresponding tournament and event slugsparameterstournament_slugstringlong-name slug for a tournamentfunction-3-recursion-seriestipped-off-12-presented-by-the-lab-gaming-centerceo-2016event_slugstringslug of the target eventmelee-singlesdragon-ball-fighterzsmash-bros-ultimatereturnsEventparse(data)parse smash.gg api data into an Event objectparametersdatajsonhttp response data from a smash.gg api callreturnsEventget_phase()get the phases of the eventreturnsPhase[]get_phase_groups()get the phase groups of the eventreturnsPhaseGroup[]get_sets()get all of the sets played for a given eventreturnsGGSet[]get_incomplete_sets()get all of the incomplete sets for a given eventreturnsGGSet[]get_completed_sets()get all of the completed sets for a given eventreturnsGGSet[]Instanceget_id()get the id property of the eventreturns intget_name()get the name property of the eventreturns stringget_slug()get the slug property of the eventreturns stringget_state()get the state property of the eventreturns stringget_start_at()get the start_at property of the eventreturns intget_num_entrants()get the num_entrants property of the eventreturns intget_check_in_buffer()get the check_in_buffer property of the eventreturns intget_check_in_duration()get the check_in_duration property of the eventreturns intget_check_in_enabled()get the check_in_enabled property of the eventreturns boolget_is_online()get the is_online property of the eventreturns boolget_team_name_allowed()get the team_name_allowed property of the eventreturns boolget_team_management_deadline()get the team_management_deadline property of the eventreturns intPhasePropertiesidintnumeric id of the phasenamestringname of the phasenum_seedsintnumber of seeds that are in the phasegroup_countintnumber of phase groups that are in the phaseMethodsStaticsget(phase_id)get data from smash.gg api and get a Phase object from itparametersphase_idintnumeric id of the phasereturnsPhaseparse(data)parse smash.gg api data into an Phase objectparametersdatajsonhttp response data from a smash.gg api callreturnsPhaseget_phase_groups()get the phase groups for the given phasereturnsPhaseGroup[]get_sets()get all of the sets played for the given phasereturnsGGSet[]get_incomplete_sets()get all of the incomplete sets for the given phasereturnsGGSet[]get_completed_sets()get all of the completed sets for the given phasereturnsGGSet[]Instanceget_id()get the id property of the Phasereturns intget_name()get the name property of the Phasereturns stringget_num_seeds()get the num_seeds property of the Phasereturns intget_group_count()get the group_count property of the Phasereturns intPhaseGroupPropertiesidintnumeric id of the phase groupdisplay_identifierstringthe name of the phase groupfirst_round_timeintunix epoch of the time the first round of this phase group beginsstateintprogress of the phase groupphase_idintnumeric id of the phase this phase group belongs towave_idintnumeric id of the wave this phase group belongs totiebreak_orderjsonthe tiebreak order for this phase groupMethodsStaticsget(phase_group_id)get data from smash.gg and get a PhaseGroup object from itparametersphase_group_idintnumeric id of the phase groupparse(data)parse smash.gg api data into a PhaseGroup objectparametersdatajsonhttp response data from a smash.gg api callreturnsPhaseGroupget_sets()get all of the sets played for the given phase groupreturnsGGSet[]get_incomplete_sets()get all of the incomplete sets for the given phase groupreturnsGGSet[]get_completed_sets()get all of the completed sets for the given phase groupreturnsGGSet[]Instanceget_id()get the id property of the phase groupreturns intget_display_identifier()get the display_identifier property of the phase groupreturns stringget_first_round_time()get the first_round_time property of the phase groupreturns intget_state()get the state property of the phase groupreturns intget_phase_id()get the phase_id property of the phase groupreturns intget_wave_id()get the wave_id property of the phase groupreturns intget_tiebreak_order()get the tiebreak_order property of the phase groupreturns jsonGGSetPropertiesidintnumeric id of the setevent_idintnumeric id of the event this set belongs tophase_group_idintnumeric id of the phase group this set belongs todisplay_scorestringdisplay string for this set.Format: Smashtag1 Score1 - Score2 Smashtag2full_round_textstringfull name of the round this set takes place inroundintnumeric identifier for the round this set takes place instarted_atintunix epoch of the time this set started atcompleted_atintunix epoch of the time this set ended atwinner_idintid number of the ofEntrantwho won the settotal_gamesinttotal number of games played in this setstateintprogress of the setplayer1Player1st player in the setplayer2Player2nd player in the setscore1intscore of player 1 in the setscore2intscore of player 2 in the setMethodsStaticsparse(data)parse smash.gg api data into a GGSet objectparametersdatajsonhttp response data from a smash.gg api callreturnsGGSetparse_display_score(display_score)parse a GGSet's display score propertyparametersdatastringdisplay score string from a GGSet objectreturns custom object:p1_tagstring or Nonesmashtag of player 1p1_scoreintscore of player 1p2_tagstring or Nonesmashtag of player 2p2_scoreintscore of player 2Instanceget_id()get the id property of the eventreturns intget_event_id()get the event_id property of the eventreturns intget_phase_group_id()get the phase_group_id property of the eventreturns intget_display_score()get the display_score property of the eventreturns stringget_full_round_text()get the full_round_text property of the eventreturns stringget_round()get the round property of the eventreturns intget_started_at()get the started_at property of the eventreturns intget_completed_at()get the completed_at property of the eventreturns intget_winner_id()get the winner_id property of the eventreturns intget_total_games()get the total_games property of the eventreturns intget_state()get the state property of the eventreturns intget_player1()get the player1 property of the eventreturnsPlayerget_player2()get the player2 property of the eventreturnsPlayerget_score1()get the score1 property of the eventreturns intget_score2()get the score2 property of the eventreturns intPlayerPropertiestagstringsmashtag/identifier for this Playerentrant_idintunique entrant id number for this Playerattendee_idsint[]array of attendee ids for the attendees who make up this PlayerMethodsStaticsparse(tag, data)parse smash.gg api data into a Player objectparameterstagstringsmashtag of the playerdatajsondata from smashgg to be parsed into entrant and attendee idsreturnsPlayerInstanceget_tag()get the tag property of this playerreturns stringget_entrant_id()get the entrant_id property of this playerreturns intget_attendee_ids()get the attendee_ids property of this playerreturns int[]EntrantPropertiesidintid number of the entrantnamestringname of the entrantevent_idintid number of the event this entrant belongs toskillintskill number of the entrantattendee_dataAttendee[]array of attendee data attached to this entrantMethodsStaticsparse(data)parse smash.gg api data into an Entrant objectparametersdatajsonhttp response data from a smash.gg api callreturnsEntrantInstanceget_id()get the id property of the Entrantreturnsget_name()get the name property of the Entrantreturnsget_event_id()get the event_id property of the Entrantreturnsget_skill()get the skill property of the Entrantreturnsget_attendee_data()get the attendee_data property of the EntrantreturnsAttendeePropertiesidintnumeric id of the attendeegamer_tagstringsmashtag of the attendeeprefixstringsponsor tag of the attendee (like PG or RCS)created_atintunix epoch of the time this attendee object was createdclaimedboolt/f for if the attendee is claimed or notverifiedboolt/f for if the attendee is verified as actually being in the tournamentplayer_idintid number of the correspondingUserobjectphone_numberstringphone number of the attendeeconnected_accountsjsonobject showing all accounts connected to this attendeecontact_infojsoncontact info of the attendeeevent_idsint[]id number of all the events this attendee enteredMethodsStaticsparse(data)parse smash.gg api data into a Attendee objectparametersdatajsonhttp response data from a smash.gg api callreturnsAttendeeInstanceget_id()get the id property of the Attendeereturnsget_gamer_tag()get the gamer_tag property of the Attendeereturnsget_prefix()get the prefix property of the Attendeereturnsget_created_at()get the created_at property of the Attendeereturnsget_claimed()get the claimed property of the Attendeereturnsget_verified()get the verified property of the Attendeereturnsget_player_id()get the player_id property of the Attendeereturnsget_phone_number()get the phone_number property of the Attendeereturnsget_connected_accounts()get the connected_accounts property of the Attendeereturnsget_contact_info()get the contact_info property of the Attendeereturnsget_event_ids()get the event_ids property of the AttendeereturnsStreamPropertiesidintnumeric id of the streamevent_idintnumeric id of the event this stream is a part oftournament_idintnumeric id of the tournament this stream is a part ofstream_namestringname of the streamnum_setupsintnumber of setups on the streamstream_sourcestringweb source of the stream, like Twitchstream_typestringthe type of the current streamstream_type_idintthe numeric type of the current streamis_onlineboolt/f for if the current stream is onlineenabledboolt/f for if the current stream is enabledfollower_countintthe number of followers the stream hasremoves_tasksboolt/f for if the current stream removes tasksstream_statusstringthe status of the current streamstream_gamestringthe game the current stream is live streamingstream_logostringthe url to the logo image of the streamMethodsStaticsget(id)get raw stream data from smashgg for the given idparametersidintidentification number of the streamreturnsStreamparse(data)parse smash.gg api data into an Stream objectparametersdatajsonhttp response data from a smash.gg api callreturnsStreamInstanceget_id()get the id property of the streamreturnsget_event_id()get the event_id property of the streamreturnsget_tournament_id()get the tournament_id property of the streamreturnsget_stream_name()get the stream_name property of the streamreturnsget_num_setups()get the num_setups property of the streamreturnsget_stream_source()get the stream_source property of the streamreturnsget_stream_type()get the stream_type property of the streamreturnsget_stream_type_id()get the stream_type_id property of the streamreturnsget_is_online()get the is_online property of the streamreturnsget_enabled()get the enabled property of the streamreturnsget_follower_count()get the follower_count property of the streamreturnsget_removes_tasks()get the removes_tasks property of the streamreturnsget_stream_status()get the stream_status property of the streamreturnsget_stream_game()get the stream_game property of the streamreturnsget_stream_logo()get the stream_logo property of the streamreturnsStreamQueuePropertiesidid of the Tournament this stream queue belongs tostreamStreamstream this queue is associated withsetsGGSet[]sets in the queueMethodsget(tournament_id)get the raw stream queue data for a given tournament idparameterstournament_idintidentification number of the tournamentreturnsStreamQueueparse(data)parse smash.gg api data into an StreamQueue objectparametersdatajsonhttp response data from a smash.gg api callreturnsStreamQueueInstanceget_stream()get the StreamQueue's stream propertyStreamget_sets()get the StreamQueue's sets propertyGGSet[]How to runNOTE:In order to use properly, you will need to create an .env file with the API_TOKEN inside of it, it should look like this:API_TOKEN=<insert smash.gg API token here>If you already have Docker installed, you may run the scripts in the /docker directory.
You need to build the container before running it, so runbuildbeforerun.
If you would like to do both consecutively, you may run thebuildAndRunscript.