Put up a REST API for Xbox Gamertag Data

Posted on May 27th

My twitter app uses a web service hosted on my site to get all the necessary Xbox Live info.... way more than the twitter app actually uses. This is a SOAP API, located here:

http://duncanmackenzie.net/services/XboxInfo.asmx

 

I know that some people prefer a more RESTful API though, so I also have another 'page' that you can call with a straight GET request and just pass the gamertag in as a query string parameter:

http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=Festive+Turkey

 

Enjoy!



Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

thanx....

Just wondering where you are getting your XBOX Live data from?

Would you consider releasing the code for this? I am currently developing an Xbox live web service and am very interested in your work. You don't appear to have a contact email address on this site, so perhaps you could get in touch with me through my website?

Thanks Duncan, once again you save me a couple hours of work.

I'm also curious if the data is coming from a public source.

im also working on an Xbox live web service and was wondering if you were going to realased the source code for the one with the GET peramater as i cant find anything like it on the net this is unique!

Ditto to what everyone above said. Would love to know the code to retrieve this information myself as I wouldn't want to use up your bandwidth for my own script usage.

Thanks a lot...

I think the API will suit my purpose of use perfectly :)

Hi Duncan,

Awesome work! but like many here I'm VERY interested in how you did that webservice.

I run a community site for Xbox users in Iceland and I'm working on a custom list of all the players here, what they are playing etc.

Since I dont want to hammer your webservice with ~600 calls every 30-60 minutes every day, can you give any inforomation on how you wrote that webservice?

I applied to the Xbox Community Developer program, but never got a reply :(

Best regards,
Sigurdur G. Gunnarsson
- Iceland / www.xbox360.is

Is the API down? I was using it on a test I was doing and now I can not get it. XML call keeps telling me the doc is empty and I only added a cache method to the script?

This service is great - though it's a shame that MS has decided to limit who has access to the APIs for Xbox Live.

Any chance that the server you connect to has the ability to get achievement info for a specified Gamertag? I've already written a small script to update Twitter with my Live status, but I'd also like to build something that can update based on Achievements that I earn.

The time stamp for the last seen, is it PST? I see a -6:00 which makes me think that it is for central time.

Just wanted to say thanks for providing these services!

This service is great! I've cooked up a nice little mod for Invision Power Board 2.3.x. It fits right into the user profile page for a nice list of games played, achievements and online status. It wouldn't be possible without your link to XBL. Thanks!

superb service i made a little friends list for my clan so we can see whos on and whos playing what

wouldnt be possible without your nice service

now i wanna work out how people can see when players unlock achievements and report it so i can get it to make a "10 recent achievement list"

Love this service. Ditto what everyone has already said, its great! - thanks for making it available. Question though..anyone know why some output for some gamertags show <LastSeen>0001-01-01T00:00:00</LastSeen> and offline, even though I can see they are really on if I go into xbox.com? Are their profiles corrupt or something?

Duncan, great post and info. I've been trying for a while to find something like this!

One problem I have though...? I have consumed your webservice in VS2005 and I am trying to get back data for my GTag, but, I keep getting error: Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

I'd prefer to use the web service rather than a get method as it's cleaner. Any help greatly appriciated. Ta.

Tony

I think this is the kind of program Ive been looking for. I am not sure since I know nothing of coding and/or how to use it. If you would be so kind as to maybe email me or even on this board let me know how to use this code, I would really appreciate it. Thanks.

the easiest way to use the info is to use a xml parser and then use the info as you wish

this is how i decided to use it
http://brownmurder.10gbfreehost.com/

i also made a gamertag learderboard and keep meaning to start a new project

hope that help you on how to use the info

Hey I was wondering if anyone could help me retrieve induvidual items of data from the XML Document using PHP.

I have so far:

<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=x2i4eva"]);

$x = $xmlDoc->documentElement;

foreach ($x->childNodes AS $item) {
print $item->nodeName . " = " . $item->nodeValue . "
";
}
?>

Sorry for double post but the code i gave above has a ] after the gamertag that shouldnt be there.

Dan,

I use CURL to first cache the xml file on my own server then simplexml to access the xml file and process it into the PHP script.

Example:

if (file_exists($file)) {

$xml = simplexml_load_file($file);

foreach ($xml->RecentGames->XboxUserGameInfo as $games)
{
print '<br>';
print '<b>' . $games->Game->Name . '</b><br> <br>';
print 'Achievements: ' . $games->Achievements . ' of ' . $games->Game->TotalAchievements . ' possible.<br> <br>';
print 'Gamer Score: ' . $games->GamerScore . ' of ' . $games->Game->TotalGamerScore . ' possible.<br>';
}

} else {

exit('Failed to open XML file.');

}

I use this ColdFusion code to cache the xml file on my server. I then setup my server to automatically run this script every 30 minutes. I then have another page that actually uses the local xml file.


<cfhttp url="http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=stolemygamertag" method="get">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="Header" name="TE" value="deflate;q=0">
</cfhttp>

<cfset gamerinfo = XMLParse(trim(cfhttp.FileContent))>

<cffile action="write" file="D:\Inetpub\razorrifh\gamerinfo\stolemygamertag.xml" output="

Thanks for the resource! I've integrated it with my personal site to show my gamer points on the last few games I've played. I use CSS to create bar charts of my progress.

http://www.joshnichols.com/xbox/