RS-api
, (*1)
Core code is from Burthorpe's runescape-api, (*2)
Installation
Dependencies
Installation
composer require vestervang/rs-api
Usage
Hiscore
require __DIR__.'/vendor/autoload.php';
use vestervang\rsApi\RS3\Hiscore;
$hiscore = new Hiscore();
$username = 'zezima';
$stats = $hiscore->getStats($username)
If you want to loop through the list of stats you can do it like this:, (*3)
for($i = 0; $i < $stats->getCount(); $i++){
$stat = $stats->getStat($i);
echo 'Name: '. $stat->getSkill()->getName(). '<br>';
echo 'Rank: '. $stat->getRank(). '<br>';
echo 'Level: '. $stat->getLevel(). '<br>';
echo 'Xp: '. $stat->getExperience(). '<br>';
echo '<br><br>';
}
Or if you want to use a foreach:, (*4)
foreach($stats->getStats() as $stat){
echo 'Name: '. $stat->getSkill()->getName(). '<br>';
echo 'Rank: '. $stat->getRank(). '<br>';
echo 'Level: '. $stat->getLevel(). '<br>';
echo 'Xp: '. $stat->getExperience(). '<br>';
echo '<br><br>';
}
GE
The only way to get a item price at the moment is by finding the id and using that., (*5)
require __DIR__.'/vendor/autoload.php';
use vestervang\rsApi\RS3\GE;
$api = new GE();
$item = $api->getItemById(4151);
I calculate the percent difference myself to get a more accurate number instead of the +0.0% og -0.0% the api returns., (*6)
Bestiary
In the bestiary api there is a option to save the result of an api call to a repo (The result will be saved to the repo as a Beast object)., (*7)
This can be turned off on a per call basis. Just send false as a second parameter and it won't save the data in the repo., (*8)
Id
require __DIR__.'/vendor/autoload.php';
$bestiary = new \vestervang\rsApi\RS3\Bestiary();
//This will save to the repo and returns the json
$beast = $bestiary->getBeastById(49);
//This call only returns the json
$beast = $bestiary->getBeastById(49, false);
This will return the json for a monster with all details., (*9)
Name
require __DIR__.'/vendor/autoload.php';
$bestiary = new \vestervang\rsApi\RS3\Bestiary();
$beast = $bestiary->getBeastByName('cow');
This will return the json for a list of beasts with names and ids., (*10)
Level
require __DIR__.'/vendor/autoload.php';
$bestiary = new \vestervang\rsApi\RS3\Bestiary();
$beast = $bestiary->getBeastsByLevel('150-300');
This will return the json for a list of beasts with names and ids., (*11)
Letter
require __DIR__.'/vendor/autoload.php';
$bestiary = new \vestervang\rsApi\RS3\Bestiary();
$beast = $bestiary->getBeastsByLetter('y');
This will return the json for a list of beasts with names and ids., (*12)
Area
This function is case-sensetive 'The Abyss' and 'The abyss' will not return the same results., (*13)
require __DIR__.'/vendor/autoload.php';
$bestiary = new \vestervang\rsApi\RS3\Bestiary();
$beast = $bestiary->getBeastsByArea('The Abyss');
This will return the json for a list of beasts with names and ids., (*14)