Skip to content

slaweally/superlig-api

Repository files navigation

TFF Süper Lig Veri API

Türkiye Futbol Federasyonu'nun Süper Lig verilerini JSON API olarak sunan sistem.

Kurulum

  1. Dosyaları sunucuya yükleyin
  2. scrape_tff.php çalıştırın
  3. results.php ile web arayüzünü görün

API Kullanımı

Veri Dosyası Dahil Etme

<?php
// Ana veri dosyasını dahil et
include '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

<?php
include '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

<?php
include '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 ($standings as $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ığı

<?php
include 'tff_superlig_data.php';

$topScorers = $tff_superlig_data['top_scorers'];

echo "<h2>Gol Krallığı</h2>";
echo "<ol>";

foreach ($topScorers as $scorer) {
    if ($scorer['goals'] > 0) {
        echo "<li>" . $scorer['name'] . " (" . $scorer['team'] . ") - " . $scorer['goals'] . " gol</li>";
    }
}

echo "</ol>";
?>

JSON API Olarak Kullanım

<?php
header('Content-Type: application/json');
include 'tff_superlig_data.php';

// Tüm veriyi JSON olarak döndür
echo json_encode($tff_superlig_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
?>

JavaScript ile AJAX Kullanımı

// Tüm verileri çek
fetch('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 cetveli
fetch('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ürleri
fetch('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 özeti
fetch('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 motoru
  • results.php - Web arayüzü
  • api.php - JSON API endpoint'i
  • refresh.php - Manuel güncelleme API'si
  • cron_update.php - Otomatik güncelleme
  • tff_superlig_data.php - Ana veri dosyası

About

Superlig Puan Durumu, Fixtür ve Gol Krallığı Api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages