Getting List Of Competitions

Competitions is the current way of working with leagues and cups. Our old leagues are now deprecated. In this guide we show how to get the full list of competitions that our football api provides.


The new kid in town

Before we start explaining how to work with competitions, we need to clarify some terms used in our football api:

  1. Competitions: is our new way of referring to any kind of football tournament that exists and that we support they include: national leagues (e.g. Premier League, LigaMX), international leagues (e.g. UEFA Champions League, UEFA Nations League), as well as national cups (e.g. Copa Del Rey, Coppa Italia, Copa Do Brasil) and international cups (e.g. UEFA Super Cup, FIFA World Cup). This includes both national teams (e.g. Brazil, France) and club teams (e.g. Real Madrid, Juventus, Manchester United).
  2. Leagues: is our old term to refer to the football tournaments that our API supports. They are now deprecated and there will be less and less support for them in terms of data and functionality. All new data and features coming up will be supported primarily with competitions!


Endpoint:

In order to get the list of all competitions that our football api provides and supports you need to call the url bellow. In this example, we have used the demo api key and secret pair. If you login in, you will see all examples with your own api key and api secret.

GET:

PARAMETERS:

This api endpoint supports several parameters that help you filter the football competitions based on countries or federations. By countries, we mean a sovereign country that can be found on the map (e.g. Russia, Italy, South Africa), and by federation we mean international football association (like: FIFA, CONMEBOL, CAF, AFC). You can read more on getting to know the countries in the getting countries list documentation page. To find out how federations work in the context of our soccer API refer to the federations specific page.

NameTypeRequiredExampleDescription
country_idnumberoptional1Will show the competitions from that specific country only
federation_idnumberoptional13Will show the competitions from that specific federation only

NOTE: If you provide both a country_id and a federation_id the country will take precedence and you will see only football competitions from that country!


Response:

If you call the URL in the box above, our football API will return a response similar to what is show in this section. First, in the table we explain what fields are there, and the follows a JSON example. However, the API works with XML too.

    NameTypeExampleDescription
    idnumber5the id of the competition which you can use as filters in other sequential requests.
    namestringSerie Athe name of the competition.
    countrieslistList with all the countries to which the competition belongs
    federationslistList with all the federations to which the competition belongs
    {
        "success": true,
        "data": {
            "competition": [
                {
                    "id": "339",
                    "name": "1. Liga Promotion",
                    "countries": [
                        {
                            "id": "9",
                            "name": "Switzerland"
                        }
                    ],
                    "federations": []
                },
                {
                    "id": "125",
                    "name": "1st Deild",
                    "countries": [
                        {
                            "id": "33",
                            "name": "Iceland"
                        }
                    ],
                    "federations": []
                },
                {
                    "id": "244",
                    "name": "Champions League",
                    "countries": [],
                    "federations": [
                        {
                            "id": "2",
                            "name": "UEFA"
                        }
                    ]
                }
            ]
        }
    }

    Examples

    The following examples show you how to use this endpoint in various programming languages. In this example, we have used the demo api key and secret pair. If you login in, you will see all examples with your own api key and api secret.

    cUrl

    curl -XGET https://livescore-api.com/api-client/competitions/list.json?key=demo_key\\&secret=demo_secret
    PHP
    file_get_contents('https://livescore-api.com/api-client/competitions/list.json?key=demo_key\&secret=demo_secret');
    Python
    import urllib2
    req = urllib2.Request('https://livescore-api.com/api-client/competitions/list.json?key=demo_key\&secret=demo_secret')
    response = urllib2.urlopen(req)
    print response.read()
    

    Getting competitions by country:

    To get the list of competitions for a certain country, you have to provide the id of the country as a get query parameter in the api endpoint URL. The parameter is country_id. In the example bellow we show you how to get all the competitions for Germany. To find our more about the countries and their ids visit the countries list documentation page.

    cUrl

    curl -XGET https://livescore-api.com/api-client/competitions/scores.json?key=demo_key\&secret=demo_secret\&country_id=2
    PHP
    file_get_contents('https://livescore-api.com/api-client/competitions/scores.json?key=demo_key&secret=demo_secret&country_id=2');
    Python
    import urllib2
    req = urllib2.Request('https://livescore-api.com/api-client/competitions/scores.json?key=demo_key&secret=demo_secret&country_id=2')
    response = urllib2.urlopen(req)
    print response.read()
    

    Getting competitions by federation:

    To get the list of competitions for a certain football federation, you have to provide the id of the federation as an http get query parameter in the same api endpoint URL. The parameter is called federation_id. In the example bellow we show you how to get all the competitions for UEFA. You can find our more about the federations and their ids in the federations list documentation page.

    cUrl

    curl -XGET https://livescore-api.com/api-client/competitions/scores.json?key=demo_key\&secret=demo_secret\&federation_id=2
    PHP
    file_get_contents('https://livescore-api.com/api-client/competitions/scores.json?key=demo_key&secret=demo_secret&federation_id=2');
    Python
    import urllib2
    req = urllib2.Request('https://livescore-api.com/api-client/competitions/scores.json?key=demo_key&secret=demo_secret&federation_id=2')
    response = urllib2.urlopen(req)
    print response.read()