|
SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br
|
|
Vive como se fosse morrer amanhã.
Estude como se fosse viver para sempre.
Einstein
|
STeams: Soccer History by APIs
Latinoware, 13/10/2021
-
Tools:
-
Internet Server: NGINX or Apache
-
PHP (Backend)
-
MySQL: MariaDB
-
Printables: $\LaTeX$
-
JavaScript (Frontend)
-
WOOIDS: My CRUDs
-
cURL: Grab web contents
-
API or Manual
-
JSON
-
API:
-
http://api.football-data.org
-
Basic Data: Free
-
More Data: Paid
-
Costs:
-
Data Requests cost Money
-
Takes Time
-
Dynamic vs Local Copy/Update
-
Howto:
-
GET https://api.football-data.org/v2/matches
-
Returns JSON
-
Array or Associated Array
-
Array of Arrays
-
cURL,
simple
use
(PHP):
-
function Curl_Url($url,$post=array())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if(!empty($post))
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt
(
$ch,
CURLOPT_HTTPHEADER,
array
(
"x-auth-token: "."your-token-here",
)
);
$result=curl_exec($ch);
curl_close($ch);
return $result;
}
-
$url="http://api.football-data.org/v2/competitions/2018";//id of competition/tournament
$result=Curl_Url($url,False);
$json=json_decode($result,True);//As associated arrays
-
{
"count":380,
"filters":{},
"competition":
{
"id":2013,
"area":
{
"id":2032,
"name":"Brazil"
},
"name":"Campeonato Brasileiro Série A",
"code":"BSA",
"plan":"TIER_ONE",
"lastUpdated":"2021-07-20T18:42:17Z"
},
"matches":
[
{
"id":325075,
"season":
{
"id":726,
"startDate":"2021-05-30",
"endDate":"2021-12-05",
"currentMatchday":26
},
"utcDate":"2021-05-29T22:00:00Z",
"status":"FINISHED","matchday":1,
"stage":"REGULAR_SEASON",
"group":null,
"lastUpdated":"2021-10-12T16:20:04Z",
"odds": {"msg":"Activate Odds-Package in User-Panel to retrieve odds."},
"score":
{
"winner":"DRAW",
"duration":"REGULAR",
"fullTime":
{
"homeTeam":2,
"awayTeam":2
},
"halfTime":
{
"homeTeam":1,"awayTeam":2
},
"extraTime":{"homeTeam":null,"awayTeam":null},
"penalties":{"homeTeam":null,"awayTeam":null}
},
"referees":[]
},
]
}
-
Save to DB or File?
-
Update Frequency (Latency)
-
Tournaments (Competitions) & Season's: Very Static
-
Tournament Teams: Very Static
-
Matches: Dynamic in Season and on MatchDay
-
Players, Goals, Referees
-
Odds...
-
Paid
-
Data:
-
Teams
-
Seasons: Scanned from Tournament (
'seasons' )
-
Tournament Teams:
competitions/teams
http://api.football-data.org/v2/competitions/2018/teams
-
Matches:
competitions/matches
http://api.football-data.org/v2/competitions/2018/matches
-
Filters:
id, season, status, matchday, group
-
Teams
-
Tournaments:
-
Seasons (Active Season)
-
Teams of Tournament/Season
-
Matches
-
Groups (Copas)
-
Rounds (MatchDays)
-
Strategy:
-
Minimize API usage
-
Tournaments, Teams & Seasons: Rarely
-
Matches: Latency, MatchDates
-
Update by Command Line Interface (CLI): Save in Files
-
Update on Access: DB
-
Pools
(Bolões):
-
Users
-
Login
-
Profiles: Public, User, Coordinator, Administrator
-
Coordinator: per Tournament, Pool
-
Pool Participants
-
Bets
-
Todo:
-
Mobile Interface (HTML)
-
Streamlined Manual Interface
-
Explore Players, Goals, Referees
-
Improve Games Search: Tournament or Tournaments
|
Messages:
0 secs.
|