https://github.com/gboquizosanchez/retroachievements
A non-official Laravel library for getting achievement, user, and game data from RetroAchievements.
https://github.com/gboquizosanchez/retroachievements
api retroachievements retroachievements-api
Last synced: 5 months ago
JSON representation
A non-official Laravel library for getting achievement, user, and game data from RetroAchievements.
- Host: GitHub
- URL: https://github.com/gboquizosanchez/retroachievements
- Owner: gboquizosanchez
- License: mit
- Created: 2024-11-25T00:38:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-24T10:51:55.000Z (about 1 year ago)
- Last Synced: 2025-08-19T11:28:49.758Z (10 months ago)
- Topics: api, retroachievements, retroachievements-api
- Language: PHP
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
RetroAchievements.org API Container for Laravel
## Summary
A library that lets you get achievement, user, and game data from RetroAchievements.org directly in your Laravel application.
## Starting π
### Prerequisites π
- Composer.
- PHP version 8.3 or higher.
## Running π οΈ
Install the package via composer:
```shell
composer require gboquizosanchez/retroachievements
```
Establish the configuration in the `.env` file:
```dotenv
RA_USERNAME=your_username
RA_WEB_API_KEY=your_api_key
```
You can also publish the configuration file to customize the package:
```shell
php artisan vendor:publish --provider="RetroAchievements\RetroAchievementsServiceProvider"
```
**Note**: You need to have a RetroAchievements account to use the API. If you don't have one, you can create one [here](https://retroachievements.org/createaccount.php). And also, you need to have a web API key. You can get one in your [control panel](https://retroachievements.org/controlpanel.php).
## Basic Usage π·
You can use two different methods:
### Using the facade
This method provides directly from ```.env``` file the username and the web API key.
```php
use Retroachievements\RetroClient;
RetroClient::getGame(gameId: 1);
```
### Using the RetroAchievements model directly
You can provide a custom username and web API key if you want to use different credentials.
Or, you can use the default ones from the ```.env``` using ```config('retro-achievements.credentials')```.
```php
use Retroachievements\Data\AuthData;
use RetroAchievements\Models\RetroAchievements;
$auth = new AuthData(
username: 'your_username',
webApiKey: 'your_api_key',
);
$client = new RetroAchievements($auth);
$client->getGame(gameId: 1);
```
### Mapping the response πΊοΈ
There are two ways to map the response. By default, the package uses the DTO mapping.
```dotenv
RA_DTO_MAPPING=true
RA_RAW_MAPPING=false
```
**Note**: If you want to use the raw mapping, you need to set the ```RA_DTO_MAPPING``` to ```false``` and the ```RA_RAW_MAPPING``` to ```true```. RAW only works with DTO mapping disabled.
## Available methods π
This package provides all methods available in the [RetroAchievements API](https://api-docs.retroachievements.org/getting-started.html).
See the [RetroClient facade](src/RetroClient.php) for more information.
## Working with βοΈ
### PHP dependencies π¦
- Spatie Laravel Data [](https://packagist.org/packages/spatie/laravel-data)
#### Develop dependencies π§
- Friendsofphp Php Cs Fixer [](https://packagist.org/packages/friendsofphp/php-cs-fixer)
- Larastan Larastan [](https://packagist.org/packages/larastan/larastan)
- Orchestra Testbench [](https://packagist.org/packages/orchestra/testbench)
- Pestphp Pest [](https://packagist.org/packages/pestphp/pest)
## Testing β
```shell
composer test
```
## Problems? π¨
Let me know about yours by [opening an issue](https://github.com/gboquizosanchez/retroachievements/issues/new)!
## Credits π§βπ»
- [GermΓ‘n Boquizo SΓ‘nchez](mailto:germanboquizosanchez@gmail.com)
- [All Contributors](../../contributors)
## License π
MIT License (MIT). See [License File](LICENSE.md).
