Games

Learn to use the Games widget and the functionalities of different tags we can use with it.

View fixtures

The list of matches that pass the filter of the provided parameters is displayed by the Games widget. These matches are automatically updated according to the frequency selected in the data-refresh parameter.

Games widget parameters

The following table contains some tags for the Games widget and their functionalities:

Tags

Type

Category

Description

data-host

String

Required

This is the hostname. It is v3.football.api-sports.io for our case.

data-key

String

Required

This parameter specifies the API key that'll be used for request validation.

data-refresh

Integer

Optional

This is an integer corresponding to the number of seconds after which the list updates. It must be an integer greater than 15. If we indicate 0 or leave this field empty, the data will not be updated automatically.

data-date

String

Optional

This is the date of the desired fixture. The format is "YYYY-MM-DD."

data-league

Integer

Optional

This contains the league ID of the league we want to view the fixtures for.

data-team

Integer

Optional

This contains the team ID of the team we want to view the fixtures for.

data-season

Integer

Optional

This contains the year of the desired season. The format is "YYYY."

data-show-errors

String

Optional

This is either true or false, depending on whether we want to display the errors.

The HTML code for using the Games widget is given below. Click the “Run” button to display the fixtures.

    html
    output
    View games

    We can change the data-date (“YYYY-MM-DD”) in line 4 to see the fixtures for another date. We can also use the data-league, data-team, and data-season tags to filter the fixtures list.

    Note: The team ID can be retrieved using the Teams information endpoint, as explained in the Teams Information lesson, and the league ID can be retrieved using the Leagues endpoint, as explained in the Support Endpoints lesson in the Appendix.

    View a single fixture

    The Game widget displays the score, events, statistics, line-ups, and players’ statistics of a specific fixture. The data-id tag dictates which fixture is displayed.

    Game widget parameters

    The following table contains the tags for the Game widget and their functionalities:

    Tags

    Type

    Category

    Description

    data-host

    String

    Required

    This is the hostname. It is v3.football.api-sports.io for our case.

    data-key

    String

    Required

    This parameter specifies the API key that'll be used for request validation.

    data-refresh

    Integer

    Optional

    This is an integer corresponding to the number of seconds after which the list updates. It must be an integer greater than 15. If we indicate 0 or leave this field empty, the data will not be updated automatically.

    data-id

    String

    Optional

    This is the ID of the fixture we want to display.

    data-league

    Integer

    Optional

    This contains the league ID of the league we want to view the fixtures for.

    data-theme

    String

    Optional

    This is used to specify the theme color that we want. If this field is left empty, the default theme will be applied; otherwise, the possible values are grey or dark.

    data-show-errors

    String

    Optional

    This is either true or false, depending on whether we want to display the errors.

    The code for the Game widget is given below. Click the “Run” button to get information for a fixture.

      html
      output
      View details of a game

      We will get the events, statistics, line-ups, and squads for the fixture. We can get information for other fixtures by changing the fixture ID in line 4.

      Note: We can use the Fixtures endpoint to get the fixture ID, as explained in the Fixtures Information lesson.