How to get Corner - 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 instant corner event and technical statistics of football matches(GMT +00:00-23:59). The event will be added, modified or deleted. Each eventId stands for an event, which will only be added or deleted. You need to synchronize the data with eventId.
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/events/corner?api_key=<YOUR_API_KEY>";
// 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": "291611716",
"homeCorner": 0,
"awayCorner": 0,
"homeHalfCorner": 0,
"awayHalfCorner": 0,
"eventList": []
},
{
"matchId": "240611710",
"homeCorner": 0,
"awayCorner": 0,
"homeHalfCorner": 0,
"awayHalfCorner": 0,
"eventList": []
},
{
"matchId": "487927711",
"homeCorner": 3,
"awayCorner": 2,
"homeHalfCorner": 3,
"awayHalfCorner": 1,
"eventList": [
{
"eventId": "4124772",
"teamId": "294",
"minute": 7
},
{
"eventId": "4124777",
"teamId": "18029",
"minute": 18
},
{
"eventId": "4124789",
"teamId": "18029",
"minute": 31
},
{
"eventId": "4124790",
"teamId": "18029",
"minute": 34
},
{
"eventId": "4124802",
"teamId": "294",
"minute": 47
}
]
},
{
"matchId": "230176614",
"homeCorner": 1,
"awayCorner": 5,
"homeHalfCorner": 1,
"awayHalfCorner": 2,
"eventList": [
{
"eventId": "4124775",
"teamId": "3917",
"minute": 5
},
{
"eventId": "4124783",
"teamId": "22560",
"minute": 17
},
{
"eventId": "4124800",
"teamId": "3917",
"minute": 45
},
{
"eventId": "4124805",
"teamId": "3917",
"minute": 52
},
{
"eventId": "4124806",
"teamId": "3917",
"minute": 58
},
{
"eventId": "4124811",
"teamId": "3917",
"minute": 81
}
]
}
]
}
Recommended Reading

How to get Stats - Football API sample code
Share the sample code using the interface call of iSports Api Sports Data www.isportsapi.com. This API endpoint returns instant technical statistics of football matches for the current day ( GMT +0 00:00-23:59 ). java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputS

How to get Events - Football API sample code
Share the sample code using the interface call of iSports Api Sports Data www.isportsapi.com. This API endpoint returns instant event of football matches for the current day( GMT +0 00:00-23:59 ), such as goals, yellow and red cards, substitution, etc. The event will be added, modified or deleted.

How to get Schedule & Results - Football API sample code
Share the sample code using the interface call of iSports Api Sports Data www.isportsapi.com. This API endpoint returns detailed information of matches. java import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.