Download the PHP package nietonchique/sofascore-api-bundle without Composer

On this page you can find all versions of the php package nietonchique/sofascore-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sofascore-api-bundle

SofaScore API Bundle

CI codecov Latest Version PHP Symfony

A Symfony bundle and standalone PHP client for the (unofficial) SofaScore API — matches, players, teams, tournaments and live per-sport statistics.

It is a faithful PHP port of the Python sofascore-wrapper library, redesigned around a pluggable transport layer, typed DTOs for the core entities, and full PHPStan (max) / Deptrac / PHPUnit coverage.

Disclaimer. This is an unofficial client and is not affiliated with, endorsed by, or supported by SofaScore. The API it talks to is undocumented and may change or block access at any time. Using it may violate SofaScore's Terms of Service — use at your own risk.

Requirements

Installation

In a Symfony application using Symfony Flex the bundle is registered automatically. Otherwise add it to config/bundles.php:

Usage

Standalone (any PHP project)

In Symfony (dependency injection)

SofascoreClient and every endpoint group are autowired services:

Endpoint groups

Access each group via the client factory methods:

Method Group Bound argument
search(string $q, int $page = 0) Search search term + page
match(?int $matchId = null) MatchEndpoint match (event) id
player(int $playerId) Player player id
playerSearch(string $query) PlayerSearch query
team(int $teamId) Team team id
league(int $leagueId) League unique-tournament id
manager(int $managerId) Manager manager id
transfers() Transfers
news() News
userData() UserData
flag(string $flagCode) Flag country code
americanFootball() / baseball() / basketball() / cricket() / esports() / iceHockey() / mma() / motorsport() / rugby() / tennis() per-sport groups

Return types

The API surface is large and SofaScore changes response fields without notice, so the return style is intentionally hybrid and predictable:

Translations

Many SofaScore entities ship an embedded fieldTranslations dictionary. The typed DTOs expose it as a ?FieldTranslations object:

LanguageCode is a convenience catalogue of known SofaScore locale codes (including the base set en, ru, sr and the codes observed in real responses). You can still pass any arbitrary string to nameIn() / shortNameIn().

For methods that return raw arrays (e.g. match()->gamesByDate()), the fieldTranslations key is preserved in the response unchanged.

Error handling

Every exception thrown by the bundle implements SofascoreExceptionInterface:

Exception Thrown when
ApiException any non-2xx / undecodable response — base class, exposes getStatusCode() and getUrl()
ApiBlockedException (extends ApiException) HTTP 403 (Cloudflare); triggers the chain fallback
NotFoundException (extends ApiException) HTTP 404 (unknown entity)
InvalidArgumentException invalid argument, e.g. an unknown sport slug

Transports & Cloudflare (403)

SofaScore sits behind Cloudflare. The bundle ships three transports behind a single TransportInterface:

The X-Requested-With header is required. SofaScore answers every API request that lacks it with a Cloudflare 403 "challenge". HttpClientTransport sends it automatically (the value is not validated — a random per-instance hex token is used to mimic the site's own XHR token), so the default http transport reaches the API directly, no browser needed.

Some IPs are geo/reputation-blocked (e.g. requests originating from Russia, or certain datacenter ranges) and get a 403 regardless of headers. Route through a clean exit with the http.proxy option — any SOCKS5/HTTP proxy works:

When still blocked, the transport raises ApiBlockedException rather than returning bogus data, and ChainTransport falls back to the Chrome transport.

Configuration (bundle)

All decorators are opt-in and disabled by default:

Quality

Run the live integration tests (they skip automatically when Cloudflare blocks the current IP):

Development

A bundle is a library — "developing" it means editing code and running the test suite (there is no app server to start). Use the host PHP (8.4+) directly:

…or run everything in Docker (no PHP needed on the host; the container runs as your user, so it leaves no root-owned files):

Using the bundle in a Dockerized app

The bundle is pure PHP; a minimal consumer image needs only PHP + ext-curl:

For the headless-Chrome fallback, also install a Chromium binary and the optional dependency (composer require chrome-php/chrome, then chrome.binary: chromium):

On a server/cloud the container's IP is a datacenter IP that Cloudflare blocks — route through a proxy (http.proxy) to a clean residential/mobile exit.

Troubleshooting

Credits

License

MIT © Aleksandr Ryzhkov


All versions of sofascore-api-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
psr/cache Version ^3.0
psr/log Version ^3.0
symfony/config Version ^8.0
symfony/dependency-injection Version ^8.0
symfony/http-client Version ^8.0
symfony/http-client-contracts Version ^3.6
symfony/http-kernel Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nietonchique/sofascore-api-bundle contains the following files

Loading the files please wait ...