How to create a live-score website

In this video tutorial, we show you how to start creating a live-score website using our soccer API. We focus on the development environment, source code repository, and then getting the current live scores.

Download from our source code starter packages to speed up your development process. Choose from technologies and programming languages like: PHP, Python, NodeJS, React, ReactNative and more.

Download source code

1. Configuration

Before we are able to begin our series on how to create a live score website, we need to configure our website with the proper API key and secret (which you can get from your profile) and also the MySQL database location and credentials.


KEY=AAAAAAAAAAAAAAAA ; the API key that you get from the live-score-api.com website
SECRET=BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ; the API secret that you get from the live-score-api.com website
DB_HOST = 'localhost' ; the webser where your database is running
DB_NAME = 'ls_local' ; the name of the database that we are going to use
DB_USER = 'root' ; the username with which we are going to access the database
DB_PASS = 'root' ; the password with which we are going to authenticate

2. Create cache table

We need to create the database table where we are going to store the responses from the live-score-api.com servers. This way, we will provide faster response to the visitors of the website and also save on our hourly request quota.


CREATE TABLE `cache` (
 `url` int(11) NOT NULL,
 `json` longtext NOT NULL,
 `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (`url`),
 UNIQUE KEY `url` (`url`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

3. Getting the live scores

Finally, we add source code in the index.php file that will use the PHP class provided in the repository (LiveScoreApi). This class will take care for all the caching and calling of our live score api services as well as all other soccer api services.


ini_set('display_errors', 'Off');
error_reporting(E_ALL);

require_once 'config.php';
require_once 'classes/LiveScoreApi.class.php';

$LiveScoreApi = new LiveScoreApi(KEY, SECRET, DB_HOST, DB_USER, DB_PASS, DB_NAME);
echo '<pre>';
var_dump($LiveScoreApi->getLivescores());

4. Next Step

How to create a livescore website (Part 2)