sixP-NaraKa / aoe2net-api-wrapper

A simple and basic Python https://aoe2.net/ API wrapper for sending `GET requests`.
MIT License
6 stars 0 forks source link

Adapt/Use new aoe2.net API functionality #3

Closed sixP-NaraKa closed 1 year ago

sixP-NaraKa commented 1 year ago

The aoe2.net site has been up for some time now again. Many changes to the required usage of their API have been made. See their API documentation below.

https://aoe2.net/#api https://aoe2.net/#nightbot

This issue is to log and implement the needed changes.

With this said, I might decide to additionally do some "mapping" of the returned responses into more user-friendly Python objects, so accessing the results is not as cumbersome as response['...'] or response.get('...') everytime. So something like this:

# Request: https://aoe2.net/api/leaderboard?game=aoe2de&leaderboard_id=3&start=1&count=10
leaderboard: Leaderboard = api.get_leaderboard(game="aoe2de", leaderboard_id=3, start=1, count=10)
print(leaderboard)
>> "Leaderboard<total = 43055, leaderboard_id = 3, start = 1, count = 10, players = [...]>"

for player in leaderboard.players  # list of players that were found
    name = player.name
    rank = player.rank
    .... = player.XXX  # etc.
sixP-NaraKa commented 1 year ago

Note: once done, a new version will be released. This version will be v2.0.0 (due to the breaking changes that need to be implemented).

sixP-NaraKa commented 1 year ago

Changes implemented in branch ISSUE-3, see commit 80320eb / 03e48e9.

Due to now mapping the API properties with dataclasses and the help of the library dataclasses-json, the Python version requirement is now 3.7+.

Will test the changes in versions 3.7+. If all looks good I'll edit the documentation and changelog, afterwards I'll merge and create the new releases.

sixP-NaraKa commented 1 year ago

Tested yesterday, looks good on 3.7+.

Updated the docs and changelog. Releasing the version v2.0.0 in a few.

sixP-NaraKa commented 1 year ago

New release available (PyPi and GitHub).