Skip to content

Commit 2a38f71

Browse files
committed
Release 0.4.0
- Add typed objects as an option - Make some arguments keyword only in the BallchasingApi class - Add some utility scripts
1 parent ce0a151 commit 2a38f71

File tree

14 files changed

+1498
-74
lines changed

14 files changed

+1498
-74
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,19 @@ for group in groups:
7373
for replay in replays:
7474
api.download_replay(replay_id=replay["id"], folder="/path/to/destination/") # You could also download like this
7575
```
76+
77+
Additionally, there's the option to put responses (replays, groups) into typed objects for better type hinting and validation.
78+
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)
79+
The classes can also be found under the `typing` folder and used as a reference for what the API returns.
80+
81+
```python
82+
# When creating the API, you can specify a default setting for typing (defaults to False)
83+
api = ballchasing.Api("Your token here", typed=True)
84+
85+
# or you can specify it explicitly
86+
replay = api.get_replay("2627e02a-aa46-4e13-b66b-b76a32069a07", typed=True)
87+
print(replay.blue.players[0].name) # Example of easy attribute access
88+
89+
group = api.get_group("g2-vs-bds-hwbf2eyolb", typed=True)
90+
print(group.players[0].name)
91+
```

ballchasing/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@
6565
TeamIdentification,
6666
Map
6767
)
68+
69+
from .typed import (
70+
ShallowReplay,
71+
ShallowGroup,
72+
DeepReplay,
73+
DeepGroup
74+
)

0 commit comments

Comments
 (0)