Skip to main content

API client for SofaScore soccer data

Project description

🇷🇺 Русский | 🇬🇧 English

PyPI Version PyPI Downloads LICENSE

Aiosofascore

Aiosofascore — асинхронный Python-клиент для SofaScore API (футбол), предоставляющий удобный доступ к данным о командах, матчах, поиску и статистике.

Возможности

  • Получение информации о командах, последних матчах, статистике
  • Поиск игроков, команд, событий, менеджеров
  • Асинхронный HTTP-клиент на базе aiohttp

Установка

pip install aiosofascore

Пример работы с командой (все основные возможности)

import asyncio
from aiosofascore.client import SofaScoreClient

TEAM_ID = 2819  # Можно заменить на нужный ID
PAGE = 0

async def main():
    client = SofaScoreClient("http://api.sofascore.com")
    # Игроки
    players = await client.team.players.get_team_players(TEAM_ID)
    print(f"\n=== Игроки команды ===")
    if players.players:
        for i, player_item in enumerate(players.players, 1):
            player = player_item.player
            print(f"{i:2d}. {player.name} | {player.position or '-'} | №{player.jerseyNumber or '-'}")
    # Последние события
    last_events = await client.team.last_events.get_last_events(TEAM_ID, PAGE)
    print(f"\n=== Последние события ===")
    for event in last_events.events:
        tournament_name = event.tournament.name if event.tournament and event.tournament.name else "-"
        print(f"Event id: {event.id}, турнир: {tournament_name}, дата: {event.startTimestamp}")
    # Производительность
    perf = await client.team.performance.get_team_performance(TEAM_ID)
    print(f"\n=== Производительность ===")
    if perf.events:
        for i, event in enumerate(perf.events[:5], 1):
            home = event.homeTeam.name if event.homeTeam else '-'
            away = event.awayTeam.name if event.awayTeam else '-'
            print(f"{i:2d}. {home} vs {away}")
            if event.homeScore and event.awayScore:
                print(f"     Счёт: {event.homeScore.current or 0} - {event.awayScore.current or 0}")
    # Рейтинги
    rankings = await client.team.rankings.get_team_rankings(TEAM_ID)
    print(f"\n=== Рейтинги ===")
    if rankings.rankings:
        for r in rankings.rankings:
            print(f"{r.rowName or '-'}: {r.ranking} место, {r.points} очков, турнир: {r.currentTournamentName}")
    # Трансферы
    transfers = await client.team.transfers.get_team_transfers(TEAM_ID)
    print(f"\n=== Входящие трансферы ===")
    if transfers.transfersIn:
        for t in transfers.transfersIn:
            print(f"{t.player.name if t.player else '-'} из {t.fromTeamName or '-'} за {t.transferFeeDescription or '-'}")
    print(f"\n=== Исходящие трансферы ===")
    if transfers.transfersOut:
        for t in transfers.transfersOut:
            print(f"{t.player.name if t.player else '-'} в {t.toTeamName or '-'} за {t.transferFeeDescription or '-'}")

if __name__ == "__main__":
    asyncio.run(main())

License

This project is licensed under the MIT License — see the LICENSE file for details.

Contact

If you have any questions or suggestions, feel free to open an issue or contact me via vasilewskij.fil@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiosofascore-0.1.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiosofascore-0.1.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file aiosofascore-0.1.1.0.tar.gz.

File metadata

  • Download URL: aiosofascore-0.1.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aiosofascore-0.1.1.0.tar.gz
Algorithm Hash digest
SHA256 6ef79565319bed2d4ab7740087ba5d79445ccfcfa5957633973cc2339ac12b1b
MD5 5d3decc836e2bdd15836d0b11b64abfc
BLAKE2b-256 ff602a8dc26b49b278a851c062fc4a0bf3748dad6f88ad28ef909ac8f031fbbf

See more details on using hashes here.

File details

Details for the file aiosofascore-0.1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiosofascore-0.1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aiosofascore-0.1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2dc9521ee709386f3dfe0d6e68bc7828f818adf31338d79bdc790174d8cfb0c5
MD5 088b7dbfd74efdb15edbfff2bc543ac0
BLAKE2b-256 11c21a8a13285ed4d97be1293497d6f12ed69e6c4007c4db6d2f76b1a7afd6aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page