A Python wrapper around the Ballchasing API
Project description
Python Ballchasing
An easy-to-use and comprehensive Python wrapper for the ballchasing.com API.
Installation
You can install the library from PyPI using pip:
pip install python-ballchasing
Authentication
Before you can use the library, you need an API authentication key from ballchasing.com.
- Log in to ballchasing.com.
- Navigate to the Upload tab.
- Create an API key and copy it.
Keep your API key secure and do not share it publicly.
API
For detailed information, please refer to the docs inside the code. For the most part it follows the API spec closely, but there are some differences.
The API is exposed via the BallchasingApi class.
Making the client:
from ballchasing import BallchasingApi
api = BallchasingApi("Your token here")
or equivalently
import ballchasing
api = ballchasing.Api("Your token here")
By default this will also ping the API to make sure it's working.
Some simple examples:
# Get lots of SSL replays
from ballchasing import Rank # there's also Playlist, Season, Map, and more
replays = api.get_replays(
min_rank=Rank.SUPERSONIC_LEGEND,
count=10_000 # The API limits you to 200 replays per request but the library handles this for you
)
for replay in replays: # (replays is an iterable so you don't need to wait for all the replays to be collected)
... # Do something with the replays
# Get a specific replay with more detail than the iterator (including stats!)
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07")
# Get groups by the "RLCS Referee" account
groups = api.get_groups(creator="76561199225615730")
for group in groups:
# Download the group
api.download_group(
group_id=group["id"],
folder="/path/to/destination/"
recursive=True, # To download all the replays and retain the group structure with subfolders
)
# Get replays from the group
replays = get_group_replays(
group_id=group["id"],
deep=True, # To get detailed replay info
)
for replay in replays:
api.download_replay(replay_id=replay["id"], folder="/path/to/destination/") # You could also download like this
Additionally, there's the option to put responses (replays, groups) into typed objects for better type hinting and validation.
It also attempts to fill in missing variables not returned by ballchasing (e.g. if a team has 0 goals they won't have a "goal" entry in the response)
The classes can also be found under the typing folder and used as a reference for what the API returns.
# When creating the API, you can specify a default setting for typing (defaults to False)
api = ballchasing.Api("Your token here", typed=True)
# or you can specify it explicitly
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07", typed=True)
print(replay.blue.players[0].name) # Example of easy attribute access
group = api.get_group("g2-vs-bds-hwbf2eyolb", typed=True)
print(group.players[0].name)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_ballchasing-0.4.1.tar.gz.
File metadata
- Download URL: python_ballchasing-0.4.1.tar.gz
- Upload date:
- Size: 23.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3005ed41e3fe34605a20d2dfebf0b6ee141b1f9241d97ea66d13b7152c7ff87f
|
|
| MD5 |
d163bde1d3992fe51880aa22c7588916
|
|
| BLAKE2b-256 |
d28580f22fec7e0ad18dbd8a9e7173a155faab4ef426246719d824135da092bd
|
Provenance
The following attestation bundles were made for python_ballchasing-0.4.1.tar.gz:
Publisher:
python-publish.yml on Rolv-Arild/python-ballchasing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_ballchasing-0.4.1.tar.gz -
Subject digest:
3005ed41e3fe34605a20d2dfebf0b6ee141b1f9241d97ea66d13b7152c7ff87f - Sigstore transparency entry: 322135948
- Sigstore integration time:
-
Permalink:
Rolv-Arild/python-ballchasing@05cd755ff7deaf38c5f061c27baf9dc7397526fe -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Rolv-Arild
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@05cd755ff7deaf38c5f061c27baf9dc7397526fe -
Trigger Event:
release
-
Statement type:
File details
Details for the file python_ballchasing-0.4.1-py3-none-any.whl.
File metadata
- Download URL: python_ballchasing-0.4.1-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61655255e392ad9565d8cbae2c23dcc2b3593dfc7f50460f34c23b777f7eb50f
|
|
| MD5 |
bdb1001b8f409a1b58fe79261a7f5f7d
|
|
| BLAKE2b-256 |
3d8733585406daca24def186e2a2d241cd90bc696f3cdcb8c4da9f76bc31eb84
|
Provenance
The following attestation bundles were made for python_ballchasing-0.4.1-py3-none-any.whl:
Publisher:
python-publish.yml on Rolv-Arild/python-ballchasing
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_ballchasing-0.4.1-py3-none-any.whl -
Subject digest:
61655255e392ad9565d8cbae2c23dcc2b3593dfc7f50460f34c23b777f7eb50f - Sigstore transparency entry: 322135955
- Sigstore integration time:
-
Permalink:
Rolv-Arild/python-ballchasing@05cd755ff7deaf38c5f061c27baf9dc7397526fe -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Rolv-Arild
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@05cd755ff7deaf38c5f061c27baf9dc7397526fe -
Trigger Event:
release
-
Statement type: