A library that lets you get achievement, user, and game data from RetroAchievements.org directly in your Laravel application.
- Composer.
- PHP version 8.3 or higher.
Install the package via composer:
composer require gboquizosanchez/retroachievements
Establish the configuration in the .env
file:
RA_USERNAME=your_username
RA_WEB_API_KEY=your_api_key
You can also publish the configuration file to customize the package:
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. And also, you need to have a web API key. You can get one in your control panel.
You can use two different methods:
This method provides directly from .env
file the username and the web API key.
use Retroachievements\RetroClient;
RetroClient::getGame(gameId: 1);
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')
.
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);
There are two ways to map the response. By default, the package uses the DTO mapping.
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.
This package provides all methods available in the RetroAchievements API.
See the RetroClient facade for more information.
composer test
Let me know about yours by opening an issue!
MIT License (MIT). See License File.