How to get Schedule & Results (Basic) - Football API sample code
Posted on June 19, 2020
Share the sample code using the interface call of iSports Api Sports Data www.isportsapi.com. This API endpoint returns the basic information of football schedule and results.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class SportDemo {
public static void main(String[] args) {
// Set url parameter
String url = "http://api.isportsapi.com/sport/football/schedule/basic?api_key=%3CYOUR_API_KEY%3E&leagueId=1639";
// Call iSport Api to get data in json format
String charset = "UTF-8";
String jsonResult = get(url, charset);
System.out.println(jsonResult);
}
/**
* @param url
* @param charset
* @return return json string
*/
public static String get(String url, String charset) {
BufferedReader reader = null;
String result = null;
StringBuffer sbf = new StringBuffer();
String userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
try {
URL newUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection)newUrl.openConnection();
connection.setRequestMethod("GET");
connection.setReadTimeout(30000);
connection.setConnectTimeout(30000);
connection.setRequestProperty("User-agent", userAgent);
connection.connect();
InputStream is = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(is, charset));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
result = sbf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
The football API returns the data as follows:
{
"code": 0,
"message": "success",
"data": [
{
"matchId": "231035710",
"leagueId": "122",
"leagueType": 1,
"leagueName": "Argentine Division 1",
"leagueShortName": "ARG D1",
"matchTime": 1564244100,
"status": -1,
"homeName": "Colon de Santa Fe",
"awayName": "Patronato Parana",
"homeScore": 0,
"awayScore": 1,
"explain": "",
"extraExplain": {
"kickOff": 0,
"minute": 0,
"homeScore": 0,
"awayScore": 0,
"extraTimeStatus": 0,
"extraHomeScore": 0,
"extraAwayScore": 0,
"penHomeScore": 0,
"penAwayScore": 0,
"twoRoundsHomeScore": 0,
"twoRoundsAwayScore": 0,
"winner": 0
},
"neutral": false
},
{
"matchId": "121035719",
"leagueId": "122",
"leagueType": 1,
"leagueName": "Argentine Division 1",
"leagueShortName": "ARG D1",
"matchTime": 1564252200,
"status": -1,
"homeName": "San Lorenzo",
"awayName": "Godoy Cruz Antonio Tomba",
"homeScore": 3,
"awayScore": 2,
"explain": "",
"extraExplain": {
"kickOff": 0,
"minute": 0,
"homeScore": 0,
"awayScore": 0,
"extraTimeStatus": 0,
"extraHomeScore": 0,
"extraAwayScore": 0,
"penHomeScore": 0,
"penAwayScore": 0,
"twoRoundsHomeScore": 0,
"twoRoundsAwayScore": 0,
"winner": 0
},
"neutral": false
}
]
}
Recommended Reading

How are sports statistics databases maintained?
Professional provider use software, while most of these statistics are still recorded manually. In terms of soccer, companies hire analysts to watch matches and document. to record scores, assists and more complicated statistics while watching live or obatain it via official channel. For instance,

Where can I find out the results of football matches?
It is clear that not all people know where to look for reliable sports information. This is especially true for beginner sports fans or operators who do not know which key points to take into account. There are so many websites which provide the latest football results and livescore from across the

Is there a free API for real-time football scores?
There are free trail API for real-time football scores, but after a time about 7 days to half a month, you might have to pay. A lot of sports data provider in the market offer such king of service right now. You can take code for free from API providers to get real-time football scores. With their