fred4jupiter / fredbet

Simple football betting application using Spring Boot, Thymeleaf and Bootstrap. Well prepared for betting with friends.
MIT License
123 stars 64 forks source link

Automatic score setting after a match #47

Open bartektartanus opened 5 months ago

bartektartanus commented 5 months ago

There is a free API that provides match results (up to 10 calls per minute). You just need to register to get a free API key and use it. The app could run every minute, check if any match is finished (more than 105 minutes after it started), and if so, call the API to get the results.

Example GET: https://api.football-data.org/v4/competitions/EC/matches?status=FINISHED&dateFrom=2024-07-14&dateTo=2024-07-14 with header: X-Auth-Token=YOUR_API_KEY will return all finished matches from that date.

Response without status=FINISHED

{
    "filters": {
        "season": "2024"
    },
    "resultSet": {
        "count": 1,
        "first": "2024-07-14",
        "last": "2024-07-14",
        "played": 0
    },
    "competition": {
        "id": 2018,
        "name": "European Championship",
        "code": "EC",
        "type": "CUP",
        "emblem": "https://crests.football-data.org/ec.png"
    },
    "matches": [
        {
            "area": {
                "id": 2077,
                "name": "Europe",
                "code": "EUR",
                "flag": "https://crests.football-data.org/EUR.svg"
            },
            "competition": {
                "id": 2018,
                "name": "European Championship",
                "code": "EC",
                "type": "CUP",
                "emblem": "https://crests.football-data.org/ec.png"
            },
            "season": {
                "id": 1537,
                "startDate": "2024-06-14",
                "endDate": "2024-07-14",
                "currentMatchday": 1,
                "winner": null
            },
            "id": 428778,
            "utcDate": "2024-07-14T19:00:00Z",
            "status": "TIMED",
            "matchday": null,
            "stage": "FINAL",
            "group": null,
            "lastUpdated": "2022-11-08T07:38:36Z",
            "homeTeam": {
                "id": null,
                "name": null,
                "shortName": null,
                "tla": null,
                "crest": null
            },
            "awayTeam": {
                "id": null,
                "name": null,
                "shortName": null,
                "tla": null,
                "crest": null
            },
            "score": {
                "winner": null,
                "duration": "REGULAR",
                "fullTime": {
                    "home": null,
                    "away": null
                },
                "halfTime": {
                    "home": null,
                    "away": null
                }
            },
            "odds": {
                "msg": "Activate Odds-Package in User-Panel to retrieve odds."
            },
            "referees": []
        }
    ]
}
fred4jupiter commented 5 months ago

Thanks for info! I will have a look at it.