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

2021
Vive como se fosse morrer amanhã.
Estude como se fosse viver para sempre.
Einstein

STeams: Soccer History by APIs

Latinoware, 13/10/2021

  1. Tools:
    1. Internet Server: NGINX or Apache
    2. PHP (Backend)
    3. MySQL: MariaDB
    4. Printables: $\LaTeX$
    5. JavaScript (Frontend)
    6. WOOIDS: My CRUDs
    7. cURL: Grab web contents
    8. API or Manual
    9. JSON
  2. API:
    1. http://api.football-data.org
    2. Basic Data: Free
    3. More Data: Paid
    4. Costs:
      1. Data Requests cost Money
      2. Takes Time
      3. Dynamic vs Local Copy/Update
    5. Howto:
      1. GET https://api.football-data.org/v2/matches
      2. Returns JSON
      3. Array or Associated Array
      4. Array of Arrays
      5. cURL, simple use (PHP):
        1. 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;
          }
        2. $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
        3. {
             "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":[]
                },
              ]
          }
      6. Save to DB or File?
      7. Update Frequency (Latency)
      8. Tournaments (Competitions) & Season's: Very Static
      9. Tournament Teams: Very Static
      10. Matches: Dynamic in Season and on MatchDay
      11. Players, Goals, Referees
      12. Odds...
      13. Paid
  3. Data:
    1. Teams
    2. Seasons: Scanned from Tournament ('seasons')
    3. Tournament Teams: competitions/teams
      http://api.football-data.org/v2/competitions/2018/teams
    4. Matches: competitions/matches
      http://api.football-data.org/v2/competitions/2018/matches
    5. Filters: id, season, status, matchday, group
    6. Teams
    7. Tournaments:
      1. Seasons (Active Season)
      2. Teams of Tournament/Season
      3. Matches
      4. Groups (Copas)
      5. Rounds (MatchDays)
  4. Strategy:
    1. Minimize API usage
    2. Tournaments, Teams & Seasons: Rarely
    3. Matches: Latency, MatchDates
    4. Update by Command Line Interface (CLI): Save in Files
    5. Update on Access: DB
  5. Pools (Bolões):
    1. Users
    2. Login
    3. Profiles: Public, User, Coordinator, Administrator
    4. Coordinator: per Tournament, Pool
    5. Pool Participants
    6. Bets
  6. Todo:
    1. Mobile Interface (HTML)
    2. Streamlined Manual Interface
    3. Explore Players, Goals, Referees
    4. Improve Games Search: Tournament or Tournaments
Messages:
0 secs.