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():
    async with SofaScoreClient() as client:
        # Игроки
        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())

Настройка HTTP-сессии

При ошибках 403 (anti-bot challenge) передайте cookies из браузера:

async with SofaScoreClient(cookies={"your_cookie": "value"}) as client:
    ...

Или через переменную окружения SOFASCORE_COOKIES (JSON). Опционально: SOFASCORE_PROXY для прокси.

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.2.0.tar.gz (14.4 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.2.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiosofascore-0.1.2.0.tar.gz
Algorithm Hash digest
SHA256 7b7fd1cd5c7edf74cc33a5ff6c1d7f18c9eedf81c255092e43ca9a327d106214
MD5 36bc969ad24e1e427f7212717a26e42d
BLAKE2b-256 81dda887cf169dc4eea47e92543826418b7d92e322ae27dc8ae91d72f405a06c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aiosofascore-0.1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c133ce1c05ec8fde2648e81e20b2a2daf38fc34f37afb4082753f25b481aa602
MD5 31cbf2a62c12e310d28ba928c42effe2
BLAKE2b-256 f0f18f844b35fbb98aabc5492f3171d7a925d6bf54d4d798f3419b77bf2093df

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