Skip to content

Latest commit

 

History

History
115 lines (74 loc) · 3.71 KB

README.md

File metadata and controls

115 lines (74 loc) · 3.71 KB

RetroAchievements Logo

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:

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.

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.

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').

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.

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.

See the RetroClient facade for more information.

Working with ⚙️

PHP dependencies 📦

  • Spatie Laravel Data Latest Stable Version

Develop dependencies 🔧

  • Friendsofphp Php Cs Fixer Latest Stable Version
  • Larastan Larastan Latest Stable Version
  • Orchestra Testbench Latest Stable Version
  • Pestphp Pest Latest Stable Version

Testing ✅

composer test

Problems? 🚨

Let me know about yours by opening an issue!

Credits 🧑‍💻

License 📄

MIT License (MIT). See License File.