Create a Fortnite Player Stats Website


In this post we are going to use the Fortnite Tracker API to get and display stats for any player. By hitting the player stats endpoint with a platform (pc, xbox, playstation), and the name of the player, we can get back their lifetime, solo, duo, and squad stats. Once we have our data, we can style it up and make it look like a Fortnite website using HTML, CSS, and PHP!

Step 1: Connect to the Fortnite API

First thing we need is an API key. This will be passed along with each call we make to any of the API endpoints.

  1. Login here https://fortnitetracker.com/site-api
  2. Click on  Manage or Create API Keys
  3. Create an Application
  4. At the bottom of your applications details page you will see your API Key.

We are going to be using the player stats endpoint to retrieve the stats on a player. The endpoint requires a platform (pc, xb1, psn), and an epic nickname.

Endpoint https://api.fortnitetracker.com/v1/profile/{platform}/{epic-nickname}

Now we will write a function to make it easy to get player stats. Using curl, we will pass along our endpoint and the correct parameters (platform, epic nickname, api key)

// place your api key here define( 'FN_API_KEY', 'YOUR-API-KEY-HERE' ); 

/** 
 * Get player stats from the fortnite api 
 * 
 * @param String $platform the epicNickname is on (pc, xb1, psn) 
 * @param String $epicNickname name of the player 
 * 
 * @return Array 
 */ 
function getPlayerStats( $platform, $epicNickname ) { // api endpoint with the platform and epicNickname 
	$apiUrlPlayerStatsEndpoint = 'https://api.fortnitetracker.com/v1/profile/' . $platform . '/' . $epicNickname; 

	// open curl call 
	$ch = curl_init(); 

	// specify our api endpoint 
	curl_setopt( $ch, CURLOPT_URL, $apiUrlPlayerStatsEndpoint ); 

	// pass along our api key as TRN-API-Key in the headers 
	curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'TRN-Api-Key:' . FN_API_KEY ) ); 

	// more curl options curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE ); 
	curl_setopt( $ch, CURLOPT_HEADER, FALSE ); 
	curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE ); 

	// get response from api and close curl 
	$response = curl_exec( $ch ); 

	curl_close( $ch ); 

	// return api response as a php array 
	return json_decode( $response, true ); 
}

Step 2: Style It Up

Once we have our data. We can go ahead and start giving it a nice Fortnite look and feel. If we want our player stats to feel like Fortnite, we need the correct font face. Here is the font face I am using.

@font-face { 
    font-family: 'Fortnite'; 
    src: url( 'BurbankBigCondensed-Bold.otf' ); 
}

Fortnite Player Stats Website

Fortnite player stats

Put everything together and we get our own Fortnite player stats website! I  highlighted the main part which is connecting to the API and the custom Fortnite font face. The rest is just simple HTML/CSS and full code is up on GitHub!

Links

Live Demo

YouTube Video

Code on GitHub

That is going to do it for this post! Leave any comments/questions/concerns below and thanks for stopping by the blog!

155 comments

  1. Write more, thaats aall I have too say. Literally, it
    seems aas hough youu relied on tthe vvideo tto mae your point.
    Yoou clearly know what youre tlking about, wwhy tthrow aweay youur intelligene on jusdt postijng videos tto your sife wyen you could bbe giving uss something informative to read?

  2. I have been exploring for a bit for any high quality articles or blog posts in this sort of area . Exploring in Yahoo I finally stumbled upon this web site. Reading this information So i’m satisfied to show that I’ve a very excellent uncanny feeling I found out exactly what I needed. I most indubitably will make certain to do not disregard this site and give it a look on a continuing basis.

  3. wonderful post, very informative. I wonder why the other specialists of this sector don’t notice this. You must continue your writing. I am confident, you have a great readers’ base already!

  4. I found your blog website on google and examine just a few of your early posts. Continue to keep up the excellent operate. I just extra up your RSS feed to my MSN News Reader. Looking for ahead to reading extra from you later on!…

  5. The following time I read a weblog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my choice to learn, but I truly thought youd have something attention-grabbing to say. All I hear is a bunch of whining about one thing that you could possibly repair if you werent too busy searching for attention.

Leave a Reply

Your email address will not be published. Required fields are marked *