package
Süper Lig API - Puan durumu - Superlig Fixtur Api
v1.0.0Açık Kaynak
Merhabalar, Geçenlerde bir haber sitesinde kullanma için TFF'nin kendi sitesinden bizzat veri okuyan bir küçük betik yapmıştım süperlig puan durumu, fixtür vb işlemleri sağlıyor. Kullanımı son derece basittir github'ta bizzat anlattım zaten ama burada da paylaşayım;
Ürün Açıklaması
Merhabalar, Geçenlerde bir haber sitesinde kullanma için TFF'nin kendi sitesinden bizzat veri okuyan bir küçük betik yapmıştım süperlig puan durumu, fixtür vb işlemleri sağlıyor.
Kullanımı son derece basittir github'ta bizzat anlattım zaten ama burada da paylaşayım;
TFF Süper Lig Veri API
Türkiye Futbol Federasyonu'nun Süper Lig verilerini JSON API olarak sunan sistem.
Kurulum
- Dosyaları sunucuya yükleyin
scrape_tff.phpçalıştırınresults.phpile web arayüzünü görün
API Kullanımı
Veri Dosyası Dahil Etme
<?php// Ana veri dosyasını dahil etinclude'tff_superlig_data.php'; // Veri yapısı$data = $tff_superlig_data; // Kullanılabilir veriler:// - $data['fixtures'] // Tüm maçlar// - $data['standings'] // Puan cetveli// - $data['clubs'] // Kulüp bilgileri// - $data['top_scorers'] // Gol krallığı// - $data['meta'] // Meta bilgiler?>
Fikstür Verilerini Kullanma
<?phpinclude'tff_superlig_data.php'; // Tüm fikstürleri al$fixtures = $tff_superlig_data['fixtures']; // Belirli haftanın maçları$week18Fixtures = array_filter($fixtures, function($match) { return$match['week'] === 18; }); // Tamamlanmış maçlar$completedMatches = array_filter($fixtures, function($match) { return$match['status'] === 'completed'; }); // Yaklaşan maçlar$upcomingMatches = array_filter($fixtures, function($match) { return$match['status'] === 'scheduled'; }); echo"Toplam maç: " . count($fixtures) . "\n"; echo"Tamamlanmış: " . count($completedMatches) . "\n"; echo"Yaklaşan: " . count($upcomingMatches) . "\n"; ?>
Puan Cetveli
<?phpinclude'tff_superlig_data.php'; $standings = $tff_superlig_data['standings']; echo"<table border='1'>"; echo"<tr><th>Sıra</th><th>Takım</th><th>O</th><th>G</th><th>B</th><th>M</th><th>P</th></tr>"; foreach ($standingsas$team) { echo"<tr>"; echo"<td>" . $team['position'] . "</td>"; echo"<td>" . $team['team'] . "</td>"; echo"<td>" . $team['played'] . "</td>"; echo"<td>" . $team['won'] . "</td>"; echo"<td>" . $team['drawn'] . "</td>"; echo"<td>" . $team['lost'] . "</td>"; echo"<td>" . $team['points'] . "</td>"; echo"</tr>"; } echo"</table>"; ?>
Gol Krallığı
<?phpinclude'tff_superlig_data.php'; $topScorers = $tff_superlig_data['top_scorers']; echo"<h2>Gol Krallığı</h2>"; echo"<ol>"; foreach ($topScorersas$scorer) { if ($scorer['goals'] > 0) { echo"<li>" . $scorer['name'] . " (" . $scorer['team'] . ") - " . $scorer['goals'] . " gol</li>"; } } echo"</ol>"; ?>
JSON API Olarak Kullanım
<?phpheader('Content-Type: application/json'); include'tff_superlig_data.php'; // Tüm veriyi JSON olarak döndürechojson_encode($tff_superlig_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); ?>
JavaScript ile AJAX Kullanımı
// Tüm verileri çekfetch('api.php').then(response=>response.json()).then(data=>{console.log('Fikstür sayısı:',data.fixtures.length);console.log('Takım sayısı:',data.standings.length);});// Sadece puan cetvelifetch('api.php?type=standings').then(response=>response.json()).then(standings=>{standings.forEach(team=>{console.log(team.position+'. '+team.team+' - '+team.points+' puan');});});// 18. hafta fikstürlerifetch('api.php?type=fixtures&week=18').then(response=>response.json()).then(fixtures=>{fixtures.forEach(match=>{console.log(match.home_team+' vs '+match.away_team);});});// İstatistik özetifetch('api.php?type=stats').then(response=>response.json()).then(stats=>{console.log('Toplam:',stats.total_fixtures,'maç');console.log('Son güncelleme:',stats.last_update);});
API Endpoint'leri
| Endpoint | Açıklama | Örnek |
|---|---|---|
api.php | Tüm veri | Tüm fikstür, puan cetveli, gol krallığı |
api.php?type=fixtures | Sadece fikstürler | Tüm haftaların maçları |
api.php?type=fixtures&week=18 | Hafta fikstürü | Sadece 18. hafta |
api.php?type=standings | Puan cetveli | Lig sıralaması |
api.php?type=clubs | Kulüpler | Takım bilgileri |
api.php?type=top_scorers | Gol krallığı | En golcü oyuncular |
api.php?type=stats | İstatistikler | Genel sayılar |
Güncelleme
Manuel Güncelleme
php scrape_tff.php
Otomatik Güncelleme (Cron)
# Crontab düzenle crontab -e # Her gün saat 02:00'da güncelle 0 2 *** /usr/bin/php /path/to/cron_update.php >> /path/to/cron.log 2>&1
Veri Yapısı
Fikstür Verisi
{ "week": 18, "home_team": "Galatasaray A.Ş.", "away_team": "Fenerbahçe A.Ş.", "home_score": 2, "away_score": 1, "status": "completed", "match_id": 283711
}Puan Cetveli
{ "position": 1, "team": "Galatasaray A.Ş.", "played": 17, "won": 13, "drawn": 3, "lost": 1, "points": 42
}Dosyalar
scrape_tff.php- Veri çekme motoruresults.php- Web arayüzüapi.php- JSON API endpoint'irefresh.php- Manuel güncelleme API'sicron_update.php- Otomatik güncellemetff_superlig_data.php- Ana veri dosyası




comments[] (0)
Henüz yorum yok. İlk yorumu siz yazın.
Yorum Yaz