An open API service indexing awesome lists of open source software.

https://github.com/tegenterter/fide-data

Library for processing open data published by FIDE for PHP
https://github.com/tegenterter/fide-data

chess library opendata php scraping

Last synced: about 1 month ago
JSON representation

Library for processing open data published by FIDE for PHP

Awesome Lists containing this project

README

          

FIDE

**Library for processing open data published by [FIDE](https://www.fide.com) for [PHP](https://php.net)**

[![Build Status](https://travis-ci.org/tegenterter/fide-data.svg?branch=master)](https://travis-ci.org/tegenterter/fide-data)

## Features

- Download all player rating XML files [published by FIDE](https://ratings.fide.com/download_lists.phtml)
- Read and parse player rating XML files

## Documentation

### Installation

Use [Composer](https://getcomposer.org) to install the library for your project:

composer require tegenterter/fide-data

### Basic Usage

```php
download(\FideData\Enum\RatingType::STANDARD, 2020, 12);

// Read and parse the rating file
$rating = new \FideData\PlayerRating($path);

/** @var \FideData\Structure\Player $player */
foreach ($rating->process() as $player) {
// Get array representation of the player object
$array = $player->toArray();

echo json_encode($array, JSON_PRETTY_PRINT) . PHP_EOL;
/**
{
"fideId": 1503014,
"name": "Carlsen, Magnus",
"federation": "NOR",
"birthYear": 1990,
"sex": "M",
"title": "GM",
"standardRating": {
"type": "standard",
"rating": 2862,
"k": 10
},
"rapidRating": null,
"blitzRating": null,
"active": true
}
*/
}
```

### Testing

The library is covered by unit tests using [PHPUnit](https://phpunit.de). You can use the following [Composer](https://getcomposer.org) script to run them:

composer run test