Skip to content

BurningYolo/get-random-recommendations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get Random Recommendations

A PHP Composer package to get random anime, manga, and game recommendations Fully Random or by some filters

This Package is wrapper for bunch of my API's present at HishuAniGami

Installation

Install the package via Composer:

composer require burningyolo/get-random-recommendations

Usage

Basic Setup

<?php

require_once 'vendor/autoload.php';

use RandomRecommendations\RecommendationClient;

$client = new RecommendationClient();

Getting Random Recommendations

Random Anime

// Get a completely random anime
$anime = $client->getRandomAnime();
echo $anime->getTitle() . " - " . $anime->getMalUrl();

// Get anime with specific tags
$anime = $client->getRandomAnime(['action', 'adventure']);
echo "Anime: " . $anime->getTitle();
echo "Type: " . $anime->getType();
echo "Episodes: " . $anime->getEpisodes();
echo "Genres: " . implode(', ', $anime->getGenres());

Random Manga

// Get a completely random manga
$manga = $client->getRandomManga();
echo $manga->getTitle() . " - " . $manga->getMalUrl();

// Get manga with specific tags
$manga = $client->getRandomManga(['romance', 'slice_of_life']);
echo "Manga: " . $manga->getTitle();
echo "Status: " . $manga->getStatus();
echo "Chapters: " . $manga->getChapters();
echo "Volumes: " . $manga->getVolumes();

Random Game

// Get a completely random game
$game = $client->getRandomGame();
echo $game->getName() . " - $" . $game->getPrice();

// Get game with specific filters
$game = $client->getRandomGame(
    ['Action', 'Adventure'],  // genres
    ['Indie', 'Singleplayer'], // tags
    29.99  // max price
);
echo "Game: " . $game->getName();
echo "Price: $" . $game->getPrice();
echo "Genres: " . implode(', ', $game->getGenres());
echo "Tags: " . implode(', ', $game->getTags());

Get All Random Recommendations at Once

$recommendations = $client->getRandomRecommendations([
    'anime_tags' => ['action', 'shounen'],
    'manga_tags' => ['romance'],
    'game_genres' => ['Indie'],
    'game_tags' => ['Anime', 'cute'],
    'max_price' => 10.00
]);

if ($recommendations['anime']) {
    echo "Anime: " . $recommendations['anime']->getTitle() . "\n";
}

if ($recommendations['manga']) {
    echo "Manga: " . $recommendations['manga']->getTitle() . "\n";
}

if ($recommendations['game']) {
    echo "Game: " . $recommendations['game']->getName() . "\n";
}

Getting Available Tags/Genres

// Get all available anime tags
$animeTags = $client->getAnimeTags();
echo "Available anime tags: " . implode(', ', $animeTags);

// Get all available manga tags
$mangaTags = $client->getMangaTags();
echo "Available manga tags: " . implode(', ', $mangaTags);

// Get all available game tags
$gameTags = $client->getGameTags();
echo "Available game tags: " . implode(', ', $gameTags);

// Get all available game genres
$gameGenres = $client->getGameGenres();
echo "Available game genres: " . implode(', ', $gameGenres);

Error Handling

use RandomRecommendations\Exceptions\ApiException;

try {
    $anime = $client->getRandomAnime(['nonexistent_tag']);
} catch (ApiException $e) {
    echo "Error: " . $e->getMessage();
}

Models

Anime Model

  • getTitle() - Get anime title
  • getMalUrl() - Get MyAnimeList URL
  • getType() - Get anime type (TV, Movie, etc.)
  • getEpisodes() - Get number of episodes
  • getGenres() - Get array of genres
  • toArray() - Get all data as array

Manga Model

  • getTitle() - Get manga title
  • getMalUrl() - Get MyAnimeList URL
  • getStatus() - Get publication status
  • getChapters() - Get number of chapters
  • getVolumes() - Get number of volumes
  • getGenres() - Get array of genres
  • toArray() - Get all data as array

Game Model

  • getName() - Get game name
  • getGameId() - Get game ID
  • getPrice() - Get game price
  • getGenres() - Get array of genres
  • getTags() - Get array of tags
  • toArray() - Get all data as array

Requirements

  • PHP 8.1 or higher
  • Guzzle HTTP client

License

MIT License

About

A PHP Composer package to get random anime, manga & game recommendations Fully Random or by some filters

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages