https://github.com/brieucthomas/ergast-client
PHP client for Ergast Developer API
https://github.com/brieucthomas/ergast-client
ergast-api php
Last synced: 5 months ago
JSON representation
PHP client for Ergast Developer API
- Host: GitHub
- URL: https://github.com/brieucthomas/ergast-client
- Owner: brieucthomas
- License: mit
- Created: 2016-04-04T19:46:10.000Z (about 10 years ago)
- Default Branch: 1.0
- Last Pushed: 2020-09-09T14:13:57.000Z (almost 6 years ago)
- Last Synced: 2025-05-04T22:07:32.567Z (about 1 year ago)
- Topics: ergast-api, php
- Language: PHP
- Homepage:
- Size: 127 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ergast Client
[](https://travis-ci.org/brieucthomas/ergast-client)
[](LICENSE.md)
[](https://github.com/brieucthomas/ergast-client/releases)
[](https://packagist.org/packages/brieucthomas/ergast-client)
PHP client for [Ergast Developer API](http://ergast.com/mrd/).
## Requirements
PHP needs to be a minimum version of PHP 7.
## Installation
This library can be easily installed via [Composer](https://getcomposer.org/):
```bash
composer require brieucthomas/ergast-client
```
or just add it to your ```composer.json``` file directly and run composer install.
## Usage
```php
use BrieucThomas\ErgastClient\ErgastClientBuilder;
use BrieucThomas\ErgastClient\Request\RequestBuilder;
$ergastClient = ErgastClientBuilder::createErgastClient();
$requestBuilder = new RequestBuilder();
$requestBuilder
->findCircuits()
->byId('monza')
;
$response = $ergastClient->execute($requestBuilder->build());
$circuit = $response->getCircuits()->first();
echo $circuit->getId(); // "monza"
echo $circuit->getName(); // "Autodromo Nazionale di Monza"
echo $circuit->getUrl(); // "http://en.wikipedia.org/wiki/Autodromo_Nazionale_Monza"
echo $circuit->getLocation()->getLocality(); // "Monza"
echo $circuit->getLocation()->getCountry(); // "Italy"
echo $circuit->getLocation()->getLatitude(); // 45.6156
echo $circuit->getLocation()->getLongitude(); // 9.28111
```
## Limit and offset
```php
$uriBuilder
->setFirstResult(2)
->setMaxResults(5)
;
```