Put up a REST API for Xbox Gamertag Data
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!




33 Comments
tajbender said
Hi there, this seems pretty cool... However, could you provide the sourcecode for this?<br />I just want to know how you get all the information from, and how you do it?
Dre said
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.
Rono said
Thanks a lot... <br /><br />I think the API will suit my purpose of use perfectly :)
Alex Atkin UK said
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.
Michael Schultz said
After about a day of trying to understand all this. I think I have a pretty good solution to simply displaying your Gamertag status. I have been searching for a way to accomplish this for such a long time. I'm so glad you have shown us the light Duncan!<br /><br />Also, big thanks to AnimuX for his code. It was a big help.<br /><br />Check out my implementation out here: http://michaelwschultz.com<br /><br />I have also written an article about how this is accomplished and have included all the source code here: http://idzr.org/e6swzs<br /><br />If you all have any questions feel free to contact me at michael@michaelwschultz.com
tajbender said
Hi there, this seems pretty cool... However, could you provide the sourcecode for this?<br />I just want to know how you get all the information from, and how you do it?
Russell said
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.
Tim said
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!
RodEllison said
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?
Dave Walker said
Just wanted to say thanks for providing these services!
Dan said
Hey I was wondering if anyone could help me retrieve induvidual items of data from the XML Document using PHP.<br /><br />I have so far:<br /><br /><?php<br />$xmlDoc = new DOMDocument();<br />$xmlDoc->load("http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=x2i4eva"]);<br /><br />$x = $xmlDoc->documentElement;<br /><br />foreach ($x->childNodes AS $item) {<br />print $item->nodeName . " = " . $item->nodeValue . "<br />";<br />}<br />?>
AnimuX said
Dan,<br /><br />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.<br /><br />Example:<br /><br />if (file_exists($file)) {<br /><br />$xml = simplexml_load_file($file);<br /><br />foreach ($xml->RecentGames->XboxUserGameInfo as $games) <br />{<br />print '<br>';<br />print '<b>' . $games->Game->Name . '</b><br> <br>';<br />print 'Achievements: ' . $games->Achievements . ' of ' . $games->Game->TotalAchievements . ' possible.<br> <br>';<br />print 'Gamer Score: ' . $games->GamerScore . ' of ' . $games->Game->TotalGamerScore . ' possible.<br>';<br />}<br /><br />} else {<br /><br />exit('Failed to open XML file.');<br /><br />}<br />
steven brown said
the easiest way to use the info is to use a xml parser and then use the info as you wish<br /><br />this is how i decided to use it<br />http://brownmurder.10gbfreehost.com/<br /><br />i also made a gamertag learderboard and keep meaning to start a new project<br /><br />hope that help you on how to use the info
Tony said
Duncan, great post and info. I've been trying for a while to find something like this!<br /><br />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.<br /><br />I'd prefer to use the web service rather than a get method as it's cleaner. Any help greatly appriciated. Ta. <br /><br />Tony
HT said
Hello Duncan,<br />Thank you for posting this great info! I guess I have the same questions as some of the people on this blog. Is it possible for you to tell me where you're getting your data from Xbox Live?<br /><br />I am working on a website and don't want to bog down your server with hundreds of request every hour. Thanks!
Dan said
Sorry for double post but the code i gave above has a ] after the gamertag that shouldnt be there.
MeeCoder said
This service is pretty cool... is the source available?
AnimuX said
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!
Russell said
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?
MeeCoder said
This service is pretty cool... is the source available?
zp said
Hi Duncan<br />Thanx for the API.<br />This is surely something i was looking for!
steven brown said
superb service i made a little friends list for my clan so we can see whos on and whos playing what<br /><br />wouldnt be possible without your nice service<br /><br />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"<br /><br />
Sigurdur G. Gunnarsson said
Hi Duncan,<br /><br />Awesome work! but like many here I'm VERY interested in how you did that webservice.<br /><br />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.<br /><br />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?<br /><br />I applied to the Xbox Community Developer program, but never got a reply :(<br /><br />Best regards,<br />Sigurdur G. Gunnarsson<br /> - Iceland / www.xbox360.is
Aaron Allport said
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?
Josh said
This service is great - though it's a shame that MS has decided to limit who has access to the APIs for Xbox Live.<br /><br />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.
fiestaxp said
thanx....
UL Legend FR said
This seems to have stopped working. Using the REST api it just says everyone is an invalid gamertag. This is a great service and it would be a shame if it wasn't saved : )
Ramon Ecung II said
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.<br /><br /><br /><cfhttp url="http://duncanmackenzie.net/services/GetXboxInfo.aspx?GamerTag=stolemygamertag" method="get"><br /> <cfhttpparam type="header" name="Accept-Encoding" value="*" /><br /> <cfhttpparam type="Header" name="TE" value="deflate;q=0"><br /></cfhttp><br /><br /><cfset gamerinfo = XMLParse(trim(cfhttp.FileContent))><br /><br /><cffile action="write" file="D:\Inetpub\razorrifh\gamerinfo\stolemygamertag.xml" output="
dan said
Thanks Duncan, once again you save me a couple hours of work. <br /><br />I'm also curious if the data is coming from a public source.
Steve Daniels said
Just wondering where you are getting your XBOX Live data from?
Josh N. said
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. <br /><br />http://www.joshnichols.com/xbox/
James Skemp said
Duncan, is this completely not available any longer? I'm getting an IIS 404 when I try the links above, and based on the link that brought me here, it appears you switched to an MVC-based Web app at some point.
Did the URL just change, or is it gone-gone?
Gundosrfo said
Aloha!icec! http://spdfrq.com dweyw ldeai http://xlpxva.com ueufk xuuek http://zyhsaj.com reitx xnmyw http://wcgvgq.com xxlqn lsphs http://fbvfch.com xxntf glxzp