SC2 Replays

Authentication
API Specification
You will find on this page a complete description of all web services this site offers. Two are available currently:
1) Upload Replay : Lets you upload replay directly to the site. Video can also be linked in the process.
2) Replays List : Returns past replays based on a criteria (can be a competition, a shoutcaster or a player).

It's free and the only restriction is that you need to link back to SC2 Replays. Contact us for more informations if your are interested in using this services.
Upload Replay
URI : POST /api/replay-upload/

Request

Parameter Method Required Description
accountid POST Yes Account identifier required for using the API (uploading rights must be set for this account)
accesskey POST Yes Access key associated to the account identifier
replayfile POST Yes The .sc2replay file encoded in base64
from POST No Name of the competition where the match took place
round POST No Round identifier of the competition following this table:
1 => "Final"
2 => "Final Lower Bracket"
3 => "Semi Final"
5 => "Quarter Final"
7 => "Last sixteen"
9 => "Last thirty two"
10 => "Qualifier"
11 => "Third place match"
uid POST No A unique identifier given by the client and only used for debugging purpose
videoplayer POST No Flash video player to use for VoD. This parameter depend of the hosting site of the video. Allowed values:
- Youtube
- Dailymotion
- Own3d
- MLG
- Blip
(video embedding rights must be set for this account)
videoid POST No Identifier for the video on the hosting site. Format depend of the site:
- Youtube : string of 11 alphanumeric characters
- Dailymotion : string of 6 alphanumeric characters
- Own3d : integer value
- MLG : integer value
- Blip : integer value
Sharing must be allowed by the owner of the video. See Terms of Use on the hosting site
shoutcaster POST No Nickname of shoutcaster(s) in the video
lang POST No Language used by the shoutcaster(s) in the video

Response

Example   
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE parse SYSTEM "http://www.sc2replays.eu/dtd/upload.dtd">
<parse>
	<error>none</error>
	<pid>ehhg-t</pid>
	<detail>
		<replayname>LDLCcomHG(T)-vs-aAaNerchio(Z)</replayname>
		<played>2012-01-11 20:23:24</played>
		<version>1.4.2</version>
		<map>Metalopolis</map>
		<length>1017</length>
		<realm>EU</realm>
		<players>
			<player>
				<nickname>aAaNerchio</nickname>
				<race>Zerg</race>
				<opening>
					<building workers="14">Hatchery</building>
					<building workers="16">Spawning pool</building>
					<building workers="34">Roach warren</building>
					<building workers="50">Hatchery</building>
					<building workers="50">Baneling nest</building>
					<building workers="50">Evolution chamber</building>
				</opening>
				<units>
					<unit pourcent="49">Zergling</unit>
					<unit pourcent="26">Roach</unit>
					<unit pourcent="12">Infestor</unit>
					<unit pourcent="9">Queen</unit>
				</units>
			</player>
			<player>
				<nickname>LDLCcomHG</nickname>
				<race>Terran</race>
				<opening>
					<building workers="12">Barracks</building>
					<building workers="15">Tech lab</building>
					<building workers="17">Command center</building>
					<building workers="20">Barracks</building>
					<building workers="20">Barracks</building>
					<building workers="20">Barracks</building>
				</opening>
				<units>
					<unit pourcent="99">Marine</unit>
					<unit pourcent="1">Reaper</unit>
				</units>
			</player>
		</players>
	</detail>
</parse>
DTD    http://www.sc2replays.eu/dtd/upload.dtd
Parameters    See below
Parameter Parent Description
error parse Message returned by the API in case of replay parsing error. Return "none" if no error occurred
pid parse Public identifier for the parsed replay (string of 6 alphanumeric characters). This identifier can be used to create link to the detailed replay page on www.sc2replays.eu or to include auto-generated banner like :
<a href="http://www.sc2replays.eu/s/rhef54"><img src="http://www.sc2replays.eu/m0/rhef54.png" /></a>

<a href="http://www.sc2replays.eu/s/rhef54"><img src="http://www.sc2replays.eu/m1/rhef54.png" /></a>
replayname detail Replay name encoded in UTF-8 and generated from players names and races. Example: MillStephano(Z)-vs-RGNKiWiKaKi(P) (detail viewing rights must be set for this account)
played detail Date and hour of the match played following the pattern: YYYY/MM/DD HH:mm:SS
version detail Version of Starcraft II needed to view this replay. Example: 1.4.1
map detail Map name type in english
length detail Replay duration in seconds
realm detail Realm name in two character. Example: KR
nickname player Player name encoded in UTF-8
race player Race of the player between: Protoss, Terran, Zerg
building opening Building name in english. Available attribute "workers" counting number of workers trained before the building
unit units Unit name in english. Available attribute "pourcent" returning proportion of the total population for this particular unit
Replays List
URI : GET /api/replays/($accoundid)/($accesskey)/($page)

Request

Parameter Method Required Description
accountid GET Yes Account identifier required for using the API (detail viewing rights must be set for this account)
accesskey GET Yes Access key associated to the account identifier
page GET Yes Page to return (starting at 0)

Response

Example   
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE replays SYSTEM "http://www.sc2replays.eu/dtd/replays.dtd">
<replays start="0" total="3">
	<replay>
		<pid>oxlm6!</pid>
		<replayname>JYP(P)-vs-FnaticRain(T)</replayname>
		<video>http://www.dailymotion.com/swf/video/xljeve</video>
		<from>IEM Guangzhou</from>
		<round></round>
		<played>2011-09-30 23:27:06</played>
		<version>1.4.1</version>
		<map>Dual Sight</map>
		<length>1429</length>
		<realm>CN</realm>
		<players>
			<player>
				<nickname>FnaticRain</nickname>
				<race>Terran</race>
				<opening>
					<building workers="12">Barracks</building>
					<building workers="15">Barracks</building>
					<building workers="15">Tech lab</building>
					<building workers="20">Reactor</building>
					<building workers="21">Command center</building>
					<building workers="25">Barracks</building>
				</opening>
				<units>
					<unit pourcent="49">Marine</unit>
					<unit pourcent="31">Marauder</unit>
					<unit pourcent="12">Ghost</unit>
					<unit pourcent="8">Medivac</unit>
				</units>
			</player>
			<player>
				<nickname>JYP</nickname>
				<race>Protoss</race>
				<opening>
					<building workers="12">Gateway</building>
					<building workers="17">Cybernetics core</building>
					<building workers="22">Robotics facility</building>
					<building workers="24">Gateway</building>
					<building workers="31">Nexus</building>
					<building workers="33">Gateway</building>
				</opening>
				<units>
					<unit pourcent="51">Zealot</unit>
					<unit pourcent="18">Stalker</unit>
					<unit pourcent="13">High templar</unit>
					<unit pourcent="9">Sentry</unit>
				</units>
			</player>
		</players>
	</replay>
	<replay>
		<pid>$6l5m3</pid>
		<replayname>LiquidJinro(T)-vs-IMNesTea(Z)</replayname>
		<video>http://www.dailymotion.com/swf/video/xlgj4t</video>
		<from>Ladder Battle.net</from>
		<round></round>
		<played>2011-09-09 11:33:32</played>
		<version>1.3.6</version>
		<map>Typhon Peaks</map>
		<length>1951</length>
		<realm>KR</realm>
		<players>
			<player>
				<nickname>LiquidJinro</nickname>
				<race>Terran</race>
				<opening>
					<building workers="12">Barracks</building>
					<building workers="16">Factory</building>
					<building workers="18">Reactor</building>
					<building workers="19">Command center</building>
					<building workers="20">Tech lab</building>
					<building workers="26">Barracks</building>
				</opening>
				<units>
					<unit pourcent="63">Marine</unit>
					<unit pourcent="20">Siege tank</unit>
					<unit pourcent="8">Medivac</unit>
					<unit pourcent="4">Viking</unit>
				</units>
			</player>
			<player>
				<nickname>IMNesTea</nickname>
				<race>Zerg</race>
				<opening>
					<building workers="15">Hatchery</building>
					<building workers="17">Spawning pool</building>
					<building workers="31">Roach warren</building>
					<building workers="41">Lair</building>
				</opening>
				<units>
					<unit pourcent="33">Zergling</unit>
					<unit pourcent="22">Mutalisk</unit>
					<unit pourcent="10">Corruptor</unit>
					<unit pourcent="10">Brood lord</unit>
				</units>
			</player>
		</players>
	</replay>
	<replay>
		<pid>hhjs$-</pid>
		<replayname>ROOTKiWiKaKi(P)-vs-SoFtBalL(Z)</replayname>
		<video>http://www.dailymotion.com/swf/video/xgd0eb</video>
		<from></from>
		<round></round>
		<played>2010-12-11 04:56:09</played>
		<version>1.1.3</version>
		<map>Metalopolis</map>
		<length>1432</length>
		<realm>US</realm>
		<players>
			<player>
				<nickname>SoFtBalL</nickname>
				<race>Zerg</race>
				<opening>
					<building workers="15">Hatchery</building>
					<building workers="15">Spawning pool</building>
					<building workers="36">Lair</building>
					<building workers="44">Hatchery</building>
					<building workers="45">Roach warren</building>
				</opening>
				<units>
					<unit pourcent="33">Roach</unit>
					<unit pourcent="27">Corruptor</unit>
					<unit pourcent="15">Zergling</unit>
					<unit pourcent="11">Hydralisk</unit>
				</units>
			</player>
			<player>
				<nickname>ROOTKiWiKaKi</nickname>
				<race>Protoss</race>
				<opening>
					<building workers="14">Gateway</building>
					<building workers="18">Cybernetics core</building>
					<building workers="25">Nexus</building>
					<building workers="25">Forge</building>
					<building workers="26">Gateway</building>
					<building workers="26">Gateway</building>
				</opening>
				<units>
					<unit pourcent="35">Stalker</unit>
					<unit pourcent="29">Void ray</unit>
					<unit pourcent="21">Zealot</unit>
					<unit pourcent="8">Sentry</unit>
				</units>
			</player>
		</players>
	</replay>
</replays>
DTD    http://www.sc2replays.eu/dtd/upload.dtd
Parameters    Returned parameters are the same as for "Upload Replay" API except that "Replays List" API returns 10 replays at a time in a "<replays>" node with two attributes :
start = starting pagination
total = total number of replays without pagination
PHP integration
You can found below an example of integrated API for PHP application
Code   
function parseReplay($uid) {
    // Read uploaded file
    $fp = fopen($_FILES['replay']['tmp_name'], 'rb');
    $data = fread($fp, filesize($_FILES['replay']['tmp_name']));

    // Encode replay in Base64
    $data64 = base64_encode($data);

    // Set Post parameters
    $array = array("accountid" => "Example",
                    "accesskey" => "********",
                    "from" => "Tournament #1",
                    "round" => 10,
                    "uid" => intval($uid),
                    "replayfile" => $data64);

    try {
        // Call SC2Replays web service
        $result = post_url_contents("http://www.sc2replays.eu/api/replay-upload/", http_build_query($array));
        if ($result !== false) {
            $dom = new DOMDocument();
            $dom->loadXML($result);
            $xpath = new DOMXpath($dom);

            // Parsing error management
            $error = $xpath->query("/parse/error");
            if (isset($error) && $error->item(0)->nodeValue != "none") {
                $logger->warn($error->item(0)->nodeValue);
            }

            // Save replay pid locally
            $pid = $xpath->query("/parse/pid");
            if (isset($pid) && $pid->item(0)->nodeValue != "") {
                $db = JFactory::getDbo();
                $db->setQuery("UPDATE yourtable 
                                SET replay_pid = '".mysql_real_escape_string($pid->item(0)->nodeValue)."' 
                                WHERE id = ".intval($uid));
                $db->query();
            }
        }
    } catch (Exception $e) {
        // Exception management
        $logger->error($e->getMessage());
    }
}

function post_url_contents($url, $postfields) {
    $crl = curl_init();
    $timeout = 20;
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($crl, CURLOPT_POST, 1);
    curl_setopt($crl, CURLOPT_POSTFIELDS, $postfields);
    $ret = curl_exec($crl);
    if ($ret === false) {
        // CURL error management
        $logger->error(curl_error($crl));
    }
    curl_close($crl);
    return $ret;
}

isset($_FILES['replay']) && $_FILES['replay']['name'] != "") {
    parseReplay($uid);
}
Follow us
  Facebook
  Twitter
  IRC
  Dailymotion
aAa Sites
- News Portal
- Progaming Team
- Shop
- WebTV