# Simple Football Highlights API integration to your application

*Presenting football highlights API aggregator that covers over +950 leagues including Premier League, Serie A, La Liga, Ligue 1 and Bundesliga.*

By [Highlightly](https://paragraph.com/@highlightly) · 2023-09-14

programming, javascript, api, web development, api integration, technology, football highlights api, highlights api

---

Nowadays, there are many API providers that offer a wide variety of sports data. Unfortunately, there are still two common issues that such applications face:

*   lack of betting information,
    
*   lack of real time highlights coverage.
    

On the market, there already are different Sport Betting APIs that tackle the previously mentioned problem, whilst highlights coverage is still a somewhat lacking topic. As a developer myself I was always looking for ways on how to integrate highlights with an already existing Football API. At the time of writing this article I found [Football Highlights API](https://highlightly.net/) by Highlightly to be one of the best options. Not only do they offer game recaps and post match interviews but also events like missed penalties, yellow/red cards, goal scoring plays & much more. I should also mention that highlights aggregation happens in real time, which is just **awesome**.

**Prerequisites for API integration**
-------------------------------------

Getting access to the above mentioned API is quite simple. As a developer you only need a [Rapid API account](https://rapidapi.com/auth/sign-up?referral=%2Fhighlightly-api-highlightly-api-default%2Fapi%2Ffootball-highlights-api%2Fpricing) to start.

Once you are successfully logged in, you can opt for the BASIC tier of the API which is **free**. I myself find the PRO tier the best, since it is quite cheap and allows you to query all data freely.

**Note:** _The API TOKEN you receive from Rapid API should be securely stored on your server. Make sure not to expose it to your clients._

**Fetching Football highlights data**
-------------------------------------

There are a lot of cool programming languages out there. Since for me Javascript is the best I will show you a couple of ways on how you can fetch Football Highlights API data (docs can be found [here](https://highlightly.net/documentation/football/)).

There are a couple of routes which we can use for data fetching:

*   **/countries** and **/countries/{countryCode}**
    
*   **/teams** and **/teams/{team\_id}**
    
*   **/leagues** and **/leagues/{league\_id}**
    
*   **/matches** and **/matches/{match\_id}**
    
*   **/highlights** and **/highlights/{highlight\_id}**
    

Country, team and league routes more or less serve a utility purpose. Since the whole point of this API is a seamless integration with other Football APIs one should be able to make simple and intuitive queries for highlights without the need of any **ids**, right?

Lets create a simple function that will trigger a HTTP request to fetch highlights data:

    const axios = require("axios");
    
    const fetchFootballHighlightsData = async (queryParams) => {
      const options = {
        method: "GET",
        url: "https://football-highlights-api.p.rapidapi.com/highlights",
        params: queryParams,
        headers: {
          "X-RapidAPI-Key": "<API TOKEN>",
          "X-RapidAPI-Host": "football-highlights-api.p.rapidapi.com",
        },
      };
    
      try {
        const response = await axios.request(options);
        console.log(response.data);
      } catch (error) {
        console.error(error);
      }
    };

Make sure to add your own **“X-RapidAPI-Key”** which is received by subscribing to any tier of the API. With this, we can fetch data however we want. E.g.:

    fetchFootballHighlightsData({
      leagueName: "Superliga",
    });

The above function call would result in the following data:

    {
        data: [
          {
            id: 2753,
            type: 'VERIFIED',
            imgUrl: 'https://cms.superliga.dk/media/5sfgnynq/sl_seo-fallback.png?width=1200',
            title: 'Superliga: FC Midtjylland vs Hvidovre',
            description: 'Game recap',
            url: 'https://superliga.dk/kampe/2023-2024/fc-midtjylland-hvidovre-if-21-07-2023',
            match: [Object]
          },
          {
            id: 3071,
            type: 'VERIFIED',
            imgUrl: 'https://cms.superliga.dk/media/5sfgnynq/sl_seo-fallback.png?width=1200',
            title: 'Superliga: Lyngby vs FC Copenhagen',
            description: 'Game recap',
            url: 'https://superliga.dk/kampe/2023-2024/lyngby-boldklub-f-c-kobenhavn-22-07-2023',
            match: [Object]
          },
          {
            id: 3748,
            type: 'VERIFIED',
            imgUrl: 'https://cms.superliga.dk/media/5sfgnynq/sl_seo-fallback.png?width=1200',
            title: 'Superliga: Odense vs Randers FC',
            description: 'Game recap',
            url: 'https://superliga.dk/kampe/2023-2024/ob-randers-fc-23-07-2023',
            match: [Object]
          },
          {
            id: 3548,
            type: 'UNVERIFIED',
            imgUrl: 'https://cms.superliga.dk/media/5sfgnynq/sl_seo-fallback.png?width=1200',
            title: 'Superliga: Silkeborg vs Brondby',
            description: null,
            url: 'https://superliga.dk/kampe/2023-2024/silkeborg-if-brondby-if-23-07-2023',
            match: [Object]
          },
          {
            id: 3944,
            type: 'UNVERIFIED',
            imgUrl: 'https://cms.superliga.dk/media/5sfgnynq/sl_seo-fallback.png?width=1200',
            title: 'Superliga: FC Nordsjaelland vs Viborg',
            description: null,
            url: 'https://superliga.dk/kampe/2023-2024/fc-nordsjaelland-viborg-ff-24-07-2023',
            match: [Object]
          },
          ...
        ],
        pagination: { totalCount: 423, offset: 0, limit: 40 }
      }

The API supports a whole variety of query parameters not just the league name as presented in the above example (you can use query fields like date, season, countryCode, countryName, etc.).

Since it would take a long time to go through all examples, I simply suggest that you visit the [Rapid API endpoint testing page](https://rapidapi.com/highlightly-api-highlightly-api-default/api/football-highlights-api) and play with the API a bit.

**Conclusion**
--------------

Real time highlights coverage is a major pain point of the current industry. We have presented a simple yet powerfull API aggregator for [Football Highlights](https://highlightly.net/), which collects highlight clips, game recaps, interviews, yellow/red cards, goal scoring moments in real time. The API itself does not only support major leagues but other lesser known ones as well. I suggest checking the BASIC plan which is **free**, to get a feel on how the API works before upgrading to the PRO plan or higher to get unlimited highlights across all leagues.

**Note**: _The BASIC plan offers support for only a subset of leagues (around 20 leagues at the time of writing this)._

---

*Originally published on [Highlightly](https://paragraph.com/@highlightly/football-highlights-api-integration)*
