Cryptyc / SC2LadderWebHost

8 stars 8 forks source link

Provide a JSON API for fetching all replays of a tournament #6

Closed Itja closed 5 years ago

Itja commented 7 years ago

To be able to implement an automated streaming service of bot tournaments, it would be beneficial if that service could access the .SC2Replay files in a standardized manner. I propose a simple JSON output on e.g. /api/tournament?season=3 which provides a json list of all replays of all games that are already done of the requested season.

I'd expect something similar to the following schema:

{ 
    "season": 3,
    "participants": ["CCZergBot", "ByunJR", "CryptBot", "Mozzarella Bot"],
    "matches": [
        { 
            "id": 458, 
            "url": "http://sc2ai.net/replays/458Mozzarella%20Bot-v-CryptBot-InterloperLE.SC2Map.Sc2Replay",
            "o1": {
                "name": "Mozzarella Bot",
                "iname": "foo8167",
                "race": "Zerg"
            },
            "o2": {
                "name": "CryptBot",
                "iname": "foo8168",
                "race": "Protoss"
            },
            "sc2version": "Base57507",
            "dataversion": "1659EF34997DA3470FF84A14431E3A86"
        },
        {
            "id": 459,
            ...
        }
    ]
}

The season and participants on the root of the JSON document are optional. Also optional are the sc2version and the dataversion - those can be used to start a replay some seconds faster (without them, SC2 will start, determine the correct version, close itself and start itself again in the correct version). As they should stay the same over the course of a single season, it might be worthwhile later on to determine them at the start and store them somewhere in the season data. However, for a first implementation of this API they can be omitted, leading to this API being more easily implemented.

A GET request to fetch this document should always be given the most recent status including all replays already finished. By keeping track of the ids of the matches, the streaming service can run right from the very beginning of the matches of the season.

Cryptyc commented 7 years ago

yeh, definately a good idea and it shouldn't be too hard to do. I'll definately have it implemented for season 3.

lladdy commented 5 years ago

@Cryptyc is this already done here? https://sc2ai.net/game_results.php

Cryptyc commented 5 years ago

Yes, this is correct, I'll close this now