PHP code example of varandas / fortnite-api
1. Go to this page and download the library: Download varandas/fortnite-api library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
varandas / fortnite-api example snippets
// Require autoload
FortniteClient;
// Get an instance of FortniteClient
$api = new FortniteClient();
$api->setKey("your api key");
/** ITEMS API **/
// Get the daily store
$data = $api->items->store();
// Get upcoming items
$data = $api->items->upcoming();
// List items
$data = $api->items->list();
// Get a random item
$data = $api->items->random();
// Get a popular item
$data = $api->items->popular();
// Get detailed data for an item
$data = $api->items->data('8403b27-7c9f125-ef5487b-552aeab');
// Search for an item
$data = $api->items->search('item name');
var_dump($data);
/** CHALLENGES **/
// Get season 3 challenges
$data = $api->challenges->get("season 3");
// Get current season challenges
$data = $api->challenges->get();
var_dump($data);
/** USERS **/
// First find a user:
$data = $api->user->id('ninja');
// After that we can query for user stats
$stats = $api->user->stats();
// If you want to query for old v1 stats:
$stats = $api->user->v1Stats();
/** WEAPONS **/
// List all current weapons:
$data = $api->weapons->get();