api-sports / public-roadmap

82 stars 5 forks source link

fixtures/statistics?fixture={fixture} response type mismatch #228

Closed kubito closed 2 years ago

kubito commented 2 years ago

Response on request fixtures/statistics?fixture=${fixture} has mismatched data type.

Property value is numeric type and sometimes it is string type.

See: curl --location --request GET 'https://v3.football.api-sports.io/fixtures/statistics?fixture=867949'

Response

{
    "get": "fixtures/statistics",
    "parameters": {
        "fixture": "867949"
    },
    "errors": [],
    "results": 2,
    "paging": {
        "current": 1,
        "total": 1
    },
    "response": [
        {
            "team": {
                "id": 63,
                "name": "Leeds",
                "logo": "https://media.api-sports.io/football/teams/63.png"
            },
            "statistics": [
                {
                    "type": "Shots on Goal",
                    "value": 4
                },
                {
                    "type": "Shots off Goal",
                    "value": 5
                },
                {
                    "type": "Total Shots",
                    "value": 12
                },
                {
                    "type": "Blocked Shots",
                    "value": 3
                },
                {
                    "type": "Shots insidebox",
                    "value": 7
                },
                {
                    "type": "Shots outsidebox",
                    "value": 5
                },
                {
                    "type": "Fouls",
                    "value": 13
                },
                {
                    "type": "Corner Kicks",
                    "value": 6
                },
                {
                    "type": "Offsides",
                    "value": null
                },
                {
                    "type": "Ball Possession",
                    "value": "40%"
                },
                {
                    "type": "Yellow Cards",
                    "value": 2
                },
                {
                    "type": "Red Cards",
                    "value": null
                },
                {
                    "type": "Goalkeeper Saves",
                    "value": 5
                },
                {
                    "type": "Total passes",
                    "value": 355
                },
                {
                    "type": "Passes accurate",
                    "value": 269
                },
                {
                    "type": "Passes %",
                    "value": "76%"
                }
            ]
        },
        {
            "team": {
                "id": 39,
                "name": "Wolves",
                "logo": "https://media.api-sports.io/football/teams/39.png"
            },
            "statistics": [
                {
                    "type": "Shots on Goal",
                    "value": 6
                },
                {
                    "type": "Shots off Goal",
                    "value": 6
                },
                {
                    "type": "Total Shots",
                    "value": 15
                },
                {
                    "type": "Blocked Shots",
                    "value": 3
                },
                {
                    "type": "Shots insidebox",
                    "value": 8
                },
                {
                    "type": "Shots outsidebox",
                    "value": 7
                },
                {
                    "type": "Fouls",
                    "value": 9
                },
                {
                    "type": "Corner Kicks",
                    "value": 4
                },
                {
                    "type": "Offsides",
                    "value": 1
                },
                {
                    "type": "Ball Possession",
                    "value": "60%"
                },
                {
                    "type": "Yellow Cards",
                    "value": null
                },
                {
                    "type": "Red Cards",
                    "value": null
                },
                {
                    "type": "Goalkeeper Saves",
                    "value": 3
                },
                {
                    "type": "Total passes",
                    "value": 546
                },
                {
                    "type": "Passes accurate",
                    "value": 463
                },
                {
                    "type": "Passes %",
                    "value": "85%"
                }
            ]
        }
    ]
}
api-sports commented 2 years ago

Hi,

This is normal because you have different possible values depending on the statistics:

You have an example in our documentation ==> https://www.api-football.com/documentation-v3#tag/Fixtures/operation/get-fixtures-statistics

Best

kubito commented 2 years ago

From perspective of designing an API it is incorrect. You should not use one property with different data type.