How to get Schedule & Results - Football API sample code
Posted on June 28, 2020
Share the sample code using the interface call of iSports Api Sports Data www.isportsapi.com. This API endpoint returns detailed information of matches.
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?api_key=<YOUR_API_KEY>&date=yyyy-MM-dd";
// 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": "311897714",
"leagueType": 1,
"leagueId": "171817",
"leagueName": "Mexico Liga MX Femenil",
"leagueShortName": "Mex MFW",
"subLeagueId": "10",
"subLeagueName": "",
"matchTime": 1566518400,
"halfStartTime": 1566522064,
"status": -1,
"homeId": "34815",
"homeName": "Aguilas de Leon (w)",
"awayId": "34305",
"awayName": "Pachuca (w)",
"homeScore": 1,
"awayScore": 1,
"homeHalfScore": 0,
"awayHalfScore": 0,
"homeRed": 0,
"awayRed": 0,
"homeYellow": 3,
"awayYellow": 0,
"homeCorner": 2,
"awayCorner": 7,
"homeRank": "",
"awayRank": "",
"season": "2019",
"round": "",
"group": "",
"location": "",
"weather": "",
"temperature": "",
"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
},
"hasLineup": false,
"neutral": false
}
]
}
Recommended Reading

How to get Livescores Changes - Football API sample code
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 livescores changes. java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLCon

How to get Livescores for Today - Football API sample code
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 livescores for today. java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLC

How to get Match Modify Record - Football API sample code
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 match modify record. java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLCo