Forgot password?
login to retroachievements.org:
User: 
Pass: 

RetroAchievements API Demo (PHP)

This page will visually demonstrate some of the functionality of the RetroAchievements PHP API. Click here to download the necessary PHP file you will need to add to your server. Once added, you will be able to create a RetroAchievements object and call functions on it, as demonstrated below. Note all highlighted code refers to a line of code in PHP. Please note, this is a beta offering and only supports read-only access to data that can already be found on the site. No personal/user data can be accessed using this API beyond what is already publically accessible for every user (username, avatar, motto and activity).

Index:

Initialize Connection to RetroAchievements:

First, you must take a copy of the RA_API.php file, store it on your server, and in the file you wish to use, create an instance of the RetroAchievements object. This only needs to be done once per pageload.

require_once( "RA_API.php" );
$RAConn = new RetroAchievements('TestUser' 'gdPk9A1UWj9IWCM9uuzcpcTSatwubnGh' );
Back to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0121s...

Get Top Ten Users by Points:

Next, simply call one of the available functions to use it. Here we fetch the top 10 users on the global leaderboards:

$data = $RAConn->GetTopTenUsers();

And here is the contents of that call. Note you are free to interpret this data, I am simply dumping it here so you can see what's in this object:

NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0214s...

Get Console IDs:

$data = $RAConn->GetConsoleIDs();
NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0208s...

Get List of all Registered Original Gameboy Games (Console ID 4):

$data = $RAConn->GetGameList( 4 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0233s...

Basic game information for Super Mario Land (GB) (Game ID 504):

$data = $RAConn->GetGameInfo( 504 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0202s...

Full game information for Super Mario Land (GB) (Game ID 504):

$data = $RAConn->GetGameInfoExtended( 504 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0194s...

Complete summary of Scott's progress in game ID 3:

$data = $RAConn->GetGameInfoAndUserProgress( 'Scott', 3 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0199s...

Scott's global rank and score:

$data = $RAConn->GetUserRankAndScore( 'Scott' );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0195s...

Scott's 10 most recently played games:

$data = $RAConn->GetUserRecentlyPlayedGames( 'Scott' );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0224s...

Scott's progress on games with IDs 2, 3 and 75:

$data = $RAConn->GetUserProgress( 'Scott', '2, 3, 75' );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0200s...

User summary of Scott, and 3 most recently played games:

$data = $RAConn->GetUserSummary( 'Scott', 3 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0192s...

Scott's latest feed (last 10 activities):

$data = $RAConn->GetFeedFor( 'Scott', 10 );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0193s...

Get Achievements Earned by Scott on January 4th 2014:

$data = $RAConn->GetAchievementsEarnedOnDay( 'Scott', '2014-01-04' );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0199s...

Get Achievements Earned by Scott overnight on New Years Eve:

$data = $RAConn->GetAchievementsEarnedBetween( 'Scott', '2013-12-31 20:00:00', '2014-01-01 04:00:00' );NULLBack to topPROFILE - http://retroachievements.org/APIDemo.php - took 0.0197s...
NB. This page uses the GPL'd software dBug to demonstrate sample data.