Skip to main content

Python Wrapper for smash.gg's GraphQL API

Project description

SmashGGPy: Python Wrapper for Smash.gg's GraphQL API

GitHub last commit PyPI GitHub

Overview

SmashGGPy is a simple wrapper for smash.gg's new GraphQL API that takes inspiration from Petercat12's PySmash, but using the GraphQL API instead of the older, slower one

Currently in Beta -- v0.2.1 right now! Will be adding features that weren't in PySmash (the inspiration, as stated above) -- See CHANGELOG.md for the most recent changes

How to install current version

Required packages

  • Requests - pip install requests

Motivation

I decided to make this project because I started working with smash.gg's API not too long ago, and I didn't have any experience using APIs or anything, and I found PySmash. It's using the older API, and its functionality is now limited. Version 1.0 of SmashGGPy has the same commands as PySmash with slightly different responses (but mostly the same) using the updated API. In the future, I am looking to add more commands.

However, I would like to say I think the best thing to do with this project if you're looking to interact with the API a lot is learn how the code works, learn how to interact with a GraphQL API, and send your own requests! I hope that this code can be of help to those who want to develop much larger applications but don't know where to start! Of course, this is going to be helpful but limited compared to the entire scope of the API, but should be very helpful nonetheless, especially in terms of getting a bunch of data.

Metadata Usage

import SmashGGPy

# Initialize the SmashGGPy class
smash = pysmashgg.SmashGG('KEY')

# All results will be returned as normal Python dictionaries

# Show meta information for a tournament
tournament = smash.tournament_show("smash-summit-10-online")
print(tournament)

# Show meta information for a tournament with bracket id for an event
tournament_with_bracket = smash.tournament_show_with_brackets("smash-summit-10-online", "melee-singles")
print(tournament_with_bracket)

# Show meta information for a tournament with bracket id for all events
tournament_with_all_brackets = tournament_show_with_brackets_all('smash-summit-10-online')
print(tournament_with_all_brackets)

Convenience Usage

import SmashGGPy
# Initialize the SmashGGPy class
smash = pysmashgg.SmashGG('KEY')

# All results will be returned as normal Python dictionaries

# Show only a list of events for a tournament (excludes meta data info)
events = smash.tournament_show_events('smash-summit-10-online')
print(events)

# Shows a complete list of sets given tournament and event names
# NOTE: page_num is the third arg, allowing you to do your own pagination.
# The result is returned as an array of dictionaries, which individually are sets with data
# I would reccomend iterating through each page until response is None, which means you're out of pages
# Normally a delay is needed in real time to avoid timing out the API
sets = smash.tournament_show_sets('smash-summit-10-online', 'melee-singles', 1)
print(sets)

# Shows a complete list of entrants given tournament and event names
# NOTE: page_num is the third arg, allowing you to do your own pagination.
# The result is returned as an array of dictionaries, which individually are sets with data
# I would reccomend iterating through each page until response is None, which means you're out of pages
# Normally a delay is needed in real time to avoid timing out the API
entrants = smash.tournament_show_entrants('smash-summit-10-online', 'melee-singles')
print(entrants)

# Shows a complete list of bracket ids given tournament and event names
brackets = smash.tournament_show_event_brackets('smash-summit-10', 'melee-singles')
print(brackets)

# Shows a complete list of bracket ids for a givern tournament and all events
brackets = tournament_show_all_event_brackets('smash-summit-10-online')

# Shows entrant info and a list of every set that entrant competed in given tournament and event names
entrant_sets = smash.tournament_show_entrant_sets('smash-summit-10-online', 'melee-singles', 'Mang0')
print(entrant_sets)

#Show sets between two entrants for a given tournament and event name
head_to_head = smash.tournament_show_head_to_head('smash-summit-10-online', 'melee-singles', 'Mang0', 'Zain')
print(head_to_head)

Bracket Usage

import SmashGGPy
# Initialize the SmashGGPy class
smash = pysmashgg.SmashGG('KEY')

# These bracket IDs are found from the tournament_show_event_brackets command, as well as others

# Shows players in a certain bracket
# NOTE: page_num is the second arg, allowing you to do your own pagination.
# The result is returned as an array of dictionaries, which individually are sets with data
# I would reccomend iterating through each page until response is None, which means you're out of pages
# Normally a delay is needed in real time to avoid timing out the API
bracket_players = smash.bracket_show_entrants(224997, 1)
print(bracket_players)

# Shows sets from a bracket
# NOTE: page_num is the second arg, allowing you to do your own pagination.
# The result is returned as an array of dictionaries, which individually are sets with data
# I would reccomend iterating through each page until response is None, which means you're out of pages
# Normally a delay is needed in real time to avoid timing out the API
bracket_sets = self.smash.bracket_show_sets(1401911, 1)
print(bracket_sets)

API Documentation

Intro

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysmashgg-0.3.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

pysmashgg-0.3.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file pysmashgg-0.3.0.tar.gz.

File metadata

  • Download URL: pysmashgg-0.3.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for pysmashgg-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0baad93cd901ba480d6bb6811756d2cb57682f0a5138b1945382f5159a017fd9
MD5 3f3aae27284fc4955f5299ad315b9429
BLAKE2b-256 8e74e49284c11f914553812fc9ad62115d9390a472305ad777aba27d0b3fac04

See more details on using hashes here.

File details

Details for the file pysmashgg-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pysmashgg-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for pysmashgg-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10f07bf202e9ed82f4d2214adf932a5aa98709901a38c58c879e316fa9ce1b90
MD5 4269608d7d7cf754d97553254a61f21b
BLAKE2b-256 c5a28d8a78745a7b1662309063de0c0b91acb8c7728ac66a9bd40694e6a34174

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page