Stats
API change historyAPI that provides statistical data about Players and Matches.
Halo Wars 2 - Match Events
Retrieves a set of Events related to the Match specified. Events are only available once the Match has completed. Events are not available for Matches played with the Custom Match Type.
The set of Events may grow over time as data becomes available.
Changelog
September 5, 2017:
- Documented new game mode "Terminus Firefight".
February 21, 2017:
- Added Endpoint.
Request
Request URL
Request parameters
-
string
An ID that uniquely identifies a Match. Match IDs can be retrieved from the "Halo Wars 2 - Player Match History" Endpoint.
Request headers
Request body
Responses
200 OK
The response body will contain the Match Events.
Representations
//
// Main Response
//
{
// Events that describe a match from start to completion. Events are reported in
// chronological order.
// Events can come in a variety of types indicated by the "EventName" field. Each event
// is documented in detail below the documentation for this return contract.
// Additional event types may be added in the future.
// When deserializing events, it is suggested to use a union of all of the fields
// across all of the different event types.
"GameEvents": [ "GameEvent" ],
// Whether this set of events accounts for the complete set of events from the match.
"IsCompleteSetOfEvents": "bool"
}
//
// BuildingConstructionQueued Event
//
// This event is fired for the following reasons:
// - A player queues a building for construction.
// - A building is provided by the scenario (for instance, the buildings a player
// starts with at the beginning of the scenario). In this case, a subsequent
// BuildingConstructionCompleted event will not be fired.
// - A building is produced by a leader power.
// - A building is built in an "upgraded" state. In this case, a
// BuildingConstructionQueued event is fired for the the "upgraded" building rather
// than firing a BuildingConstructionQueued event for the "non-upgraded" building
// followed by a subsequent BuildingUpgraded event.
//
{
// Index of the player that will control building that was queued for construction.
"PlayerIndex": "int",
// ID that indicates the type of the building. Buildings are available via the Metadata
// API as Game Objects.
"BuildingId": "string",
// Instance ID that identifies the building. The building will be referred to by this
// ID in subsequent events.
"InstanceId": "int",
// Location that the building will be created at.
"Location": {
"x": "double",
"y": "double",
"z": "double"
},
// Supply cost paid to construct the building.
"SupplyCost": "int",
// Energy cost paid to construct the building.
"EnergyCost": "int",
// Length of the construction queue after enqueuing the building.
"QueueLength": "int",
// Whether the building was queued by the player or the scenario.
"ProvidedByScenario": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "EventName"
}
//
// BuildingConstructionCompleted Event
//
// This event is fired when a building is successfully constructed.
//
{
// Index of the player that controls the building that was constructed.
"PlayerIndex": "int",
// Instance of the building that was constructed.
"InstanceId": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "BuildingConstructionCompleted"
}
//
// BuildingRecycled Event
//
// This event is fired when a building is recycled.
//
{
// Index of the player that controls the building that was recycled.
"PlayerIndex": "int",
// Instance of the building that was recycled.
"InstanceId": "int",
// Supply earned from recycling the building.
"SupplyEarned": "int",
// Energy earned from recycling the building.
"EnergyEarned": "int",
// Whether the building was recycled by the player or the scenario.
"ProvidedByScenario": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "BuildingRecycled"
}
//
// BuildingUpgraded Event
//
// This event is fired when a building is upgraded.
//
{
// Index of the player that controls the building that was upgraded.
"PlayerIndex": "int",
// ID that indicates the new type of the building. Buildings are available via the
// Metadata API as Game Objects.
"NewBuildingId": "string",
// Instance ID of the building that was upgraded.
"InstanceId": "int",
// Supply cost paid to upgrade the building.
"SupplyCost": "int",
// Energy cost paid to upgrade the building.
"EnergyCost": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "BuildingUpgraded"
}
//
// CardCycled Event
//
// This event is fired when a card is cycled.
//
{
// Index of the player that cycled a card.
"PlayerIndex": "int",
// Mana cost paid to cycle the card.
"ManaCost": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "CardCycled"
}
//
// CardPlayed Event
//
// This event is fired when a card is played.
//
{
// Index of the player that played a card.
"PlayerIndex": "int",
// ID that indicates the type of the card. Cards are available via the Metadata API.
"CardId": "guid",
// Instance ID that identifies this cast of the card. This instance will be referred to
// by this ID in subsequent events.
"InstanceId": "int",
// Mana cost paid to play the card.
"ManaCost": "int",
// Location where the card was played.
"TargetLocation": {
"x": "double",
"y": "double",
"z": "double"
},
// Whether the card was played in the base.
"SpawnAtBase": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "CardPlayed"
}
//
// Death Event
//
// This event is fired when a building or unit is destroyed.
//
{
// Index of the player that controlled the building or unit that was destroyed.
"VictimPlayerIndex": "int",
// ID that indicates the type of the building or unit that was destroyed. Game Objects
// are available via the Metadata API.
"VictimObjectTypeId": "string",
// Instance ID of the building or unit that was destroyed.
"VictimInstanceId": "int",
// Whether the death was considered a suicide.
"IsSuicide": "bool",
// Participants that contributed to the destruction of the building or unit.
// Participants are grouped by player, then object, then combat stats.
"Participants": {
// Index of the player that participated in the destruction.
"int": {
// Objects that participated in the destruction that were owned by the given
// player. Object participants are grouped by object then combat stats.
"ObjectParticipants": {
// ID that indicates the type of the building or unit that participated in the
// destruction. Game Objects are available via the Metadata API.
"string": {
// Number of objects of the given type owned by the given player that
// participated in the destruction.
"Count": "int",
// Information about the combat stats across all the objects of the given type
// owned by the given player that participated in the destruction. Combat stats
// are grouped by damage type.
"CombatStats": {
// Damage type dealt by the object of the given type. This field will contain
// one of the following values:
// Basic = 0,
// LeaderPower = 1,
// LeaderPowerNonFlying = 2,
// AntiInfantry = 3,
// Fire = 4,
// AntiBuildingFire = 5,
// SmallArms = 6,
// AASmallArms = 7,
// SmallArmsScouts = 8,
// MediumArms = 9,
// ChainGun = 10,
// ArmorPiercing = 11,
// AntiVehicle = 12,
// FuelRod = 13,
// BansheeFuelRod = 14,
// AntiAir = 15,
// Explosive = 16,
// TankExplosive = 17,
// Artillery = 18,
// Missile = 19,
// Grenade = 20,
// Demolition = 21,
// Beam = 22,
// WarthogRam = 23,
// GaussCannon = 24,
// BruteShot = 25,
// Melee = 26,
// SuicideGrunt = 27,
// SuicideGruntAV = 28,
// SuperSentinel = 29,
// Hero = 30,
// CampaignHero = 31,
// ScarabBeam = 32,
// Unknown = 255
// Additional damage types may be added in the future.
"int": {
// Number of attacks of the given damage type that were successfully landed
// on the victim building or unit.
"AttacksLanded": "int"
}
}
}
}
}
},
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "Death"
}
//
// FirefightWaveCompleted Event
//
// This event is fired when a team successfully clears a Firefight wave.
//
{
// Wave number that was completed.
"WaveNumber": "int",
// Elapsed time, measured in milliseconds, that the team took to clear the wave.
"WaveDurationMilliseconds": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "FirefightWaveCompleted"
}
//
// FirefightWaveSpawned Event
//
// This event is fired when a Firefight wave has been spawned.
//
{
// Wave number that was spawned.
"WaveNumber": "int",
// Instance IDs of the buildings and units that make up the wave.
"InstancesSpawned": [ "int" ],
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "FirefightWaveSpawned"
}
//
// FirefightWaveStarted Event
//
// This event is fired when a Firefight wave has started.
//
{
// Wave number that was started.
"WaveNumber": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "FirefightWaveStarted"
}
//
// LeaderPowerCast Event
//
// This event is fired when a leader power is cast.
//
{
// Index of the player that cast the leader power.
"PlayerIndex": "int",
// ID that indicates the type of the leader power. Leader Powers are available via the
// Metadata API.
"PowerId": "string",
// Instance ID that identifies this cast of the leader power. This instance will be
// referred to by this ID in subsequent events.
"InstanceId": "int",
// Location where the leader power was cast.
"TargetLocation": {
"x": "double",
"y": "double",
"z": "double"
},
// Supply cost paid to cast the leader power.
"SupplyCost": "int",
// Energy cost paid to cast the leader power.
"EnergyCost": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "LeaderPowerCast"
}
//
// LeaderPowerUnlocked Event
//
// This event is fired when a leader power is unlocked.
//
{
// Index of the player that unlocked the leader power.
"PlayerIndex": "int",
// ID that indicates the type of the leader power. Leader Powers are available via the
// Metadata API.
"PowerId": "string",
// Command point cost paid to unlock the leader power.
"CommandPointCost": "int",
// Whether the leader power was unlocked by the scenario.
"ProvidedByScenario": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "LeaderPowerUnlocked"
}
//
// ManaOrbCollected Event
//
// This event is fired when a mana orb is collected.
//
{
// Index of the player that collected the mana orb.
"PlayerIndex": "int",
// Instance ID of the unit that collected the mana orb.
"CollectorInstanceId": "int",
// Increase to the player's mana generation rate.
"ManaRateIncrease": "int",
// Location of the mana orb that was collected.
"Location": {
"x": "double",
"y": "double",
"z": "double"
},
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "ManaOrbCollected"
}
//
// MatchEnd Event
//
// This event is fired when the match ends.
//
{
// Reason the match ended. This field will contain one of the following values:
// Unknown = 0,
// Completed = 1,
// StartedNewMission = 2,
// EveryoneDisconnected = 3,
// InviteAccepted = 4
"MatchEndReason": "int",
// Reason the winning team achieved victory. This field will contain one of the
// following values:
// EndedPrematurely = 0,
// ObjectiveCompleted = 1,
// OpponentsEliminated = 2,
// Unknown = 255
"VictoryCondition": "int",
// Elapsed time, measured in milliseconds, spent playing the match.
"ActivePlaytimeMilliseconds": "int",
// Ending states for the teams in the match.
"TeamState": {
// Team ID.
"int": {
// Score for the team.
"ObjectiveScore": "int",
// Outcome for the team. This field will contain one of the following values:
// Unknown = 0,
// Win = 1,
// Loss = 2,
// Tie = 3
"MatchOutcome": "int"
}
},
// Ending states for the players in the match.
"PlayerState": {
// Player Index.
"int": {
// Score for the player.
"PersonalScore": "int"
}
},
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "MatchEnd"
}
//
// MatchStart Event
//
// This event is fired when the match starts.
//
{
// ID of the match.
"MatchId": "guid",
// Game mode. This field will contain one of the following values:
// Unknown = 0,
// CampaignSolo = 1,
// CampaignCooperative = 2,
// Deathmatch = 3,
// Domination = 4,
// Strongholds = 5,
// Blitz = 6,
// Firefight = 7,
// NormalTutorial = 8,
// BlitzTutorial = 9,
// TerminusFirefight = 10
"GameMode": "int",
// Match type. This field will contain one of the following values:
// Unknown = 0,
// Campaign = 1,
// Custom = 2,
// Matchmaking = 3
"MatchType": "int",
// ID of the map. Maps are available via the Metadata API.
"MapId": "string",
// Playlist the match occurred in if the match occurred in a playlist; otherwise, empty
// Guid.
"PlaylistId": "guid",
// Max team size for the match.
"TeamSize": "int",
// whether the match is using the default rule set.
"IsDefaultRuleSet": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "MatchStart"
}
//
// PlayerEliminated Event
//
// This event is fired when a player is eliminated from the match.
//
{
// Index of the player that was eliminated.
"PlayerIndex": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PlayerEliminated"
}
//
// PlayerJoinedMatch Event
//
// This event is fired at the start of the match for each player in the match. This event
// is fired for the neutral players in addition to the Human and Computer players.
//
{
// Index of the player that joined the match. The player will be referred to by this
// index in subsequent events.
"PlayerIndex": "int",
// Type of the player that joined the match. This field will contain one of the
// following values:
// Unknown = 0,
// Human = 1,
// Computer = 2,
// NPC = 3
"PlayerType": "int",
// Identify of the player if this is a human player; otherwise, null.
"HumanPlayerId": {
// Gamertag of the player.
"Gamertag": "string",
// Internal use. This will always be null.
"Xuid": null
},
// ID of the computer player if this is a computer player; otherwise, null.
"ComputerPlayerId": "int",
// Difficulty of the computer player if this is a computer player; otherwise, null.
// Difficulties are available via the Metadata API.
"ComputerDifficulty": "int",
// Team the player is a member of.
"TeamId": "int",
// Leader the player is using. Leaders are available via the Metadata API.
"LeaderId": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PlayerJoinedMatch"
}
//
// PlayerLeftMatch Event
//
// This event is fired when a player leaves the match early for any reason. This is not
// to be confused with the PlayerEliminated event. If a player is eliminated, the
// PlayerEliminated event will be fired. The player may continue to spectate the match
// after being eliminated. If the player stops spectating the match, then this event will
// be fired.
//
{
// Index of the player that left the match.
"PlayerIndex": "int",
// Elapsed time, measured in milliseconds, the player spent playing the match.
"TimeInMatchMilliseconds": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PlayerLeftMatch"
}
//
// PointCaptured Event
//
// This event is fired when an objective is captured in all game modes besides Blitz.
//
{
// Index of the player that captured the objective.
"PlayerIndex": "int",
// Instance ID of the objective that was captured.
"InstanceId": "int",
// Instance ID of the unit that captured the objective.
"CapturerInstanceId": "int",
// Location of the unit that captured the objective.
"CapturerLocation": {
"x": "double",
"y": "double",
"z": "double"
},
// ID of the team that now owns the objective. If the objective is not owned by a team,
// this will be 0.
"NewOwningTeamId": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PointCaptured"
}
//
// PointCreated Event
//
// This event is fired at the start of the match for each objective that can be captured
// on the map.
//
{
// ID that indicates the type of the objective.
"PointId": "string",
// Instance ID that identifies the objective. The objective will be referred to by this
// ID in subsequent events.
"InstanceId": "int",
// Location of the objective.
"Location": {
"x": "double",
"y": "double",
"z": "double"
},
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PointCreated"
}
//
// PointStatusChange Event
//
// This event is fired when an objective is captured in the Blitz game mode.
//
{
// Instance ID of the objective that was captured.
"InstanceId": "int",
// Updated status of the objective. This field will contain one of the following values:
// Neutral = 0,
// Contested = 1,
// Captured = 2
"Status": "int",
// ID of the team that now owns the objective. If the objective is not owned by a team,
// this will be 255.
"OwningTeamId": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "PointStatusChange"
}
//
// ResourceHeartbeat Event
//
// This event is fired at the start of a match and then at regular 5 seconds thereafter.
//
{
// Current resources for each team.
"TeamResources": {
// Team ID.
"int": {
// Current objective score for the team.
"ObjectiveScore": "int"
}
},
// Current resources for each player.
"PlayerResources": {
// Player Index.
"int": {
// Current supply balance for the player.
"Supply": "int",
// Total supply generated by the player throughout the match.
"TotalSupply": "int",
// Current energy balance for the player.
"Energy": "int",
// Total energy generated by the player throughout the match.
"TotalEnergy": "int",
// Current population count for the player.
"Population": "int",
// Current maximum population for the player.
"PopulationCap": "int",
// Current tech level for the player.
"TechLevel": "int",
// Current command point balance for the player.
"CommandPoints": "int",
// Total command points generated by the player throughout the match.
"TotalCommandPoints": "int",
// Current mana balance for the player.
"Mana": "int",
// Total mana generated by the player throughout the match.
"TotalMana": "int",
// Unused.
"ManaRate": "int",
// Current command XP for the player.
"CommandXP": "int"
}
},
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "EventName"
}
//
// ResourceTransferred Event
//
// This event is fired when a player transfers resources to another player.
//
{
// Index of the player that sent the resources.
"SendingPlayerIndex": "int",
// Index of the player that received the resources.
"ReceivingPlayerIndex": "int",
// Supply cost paid by the sending player to send the resource.
"SupplyCost": "int",
// Energy cost paid by the sending player to send the resource.
"EnergyCost": "int",
// Supply earned by the receiving player.
"SupplyEarned": "int",
// Energy earned by the receiving player.
"EnergyEarned": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "ResourceTransferred"
}
//
// TechResearched Event
//
// This event is fired when a tech is researched.
//
{
// Index of the player that received the researched tech.
"PlayerIndex": "int",
// ID that indicates the type of the tech that was researched. Techs are available via
// the Metadata API.
"TechId": "string",
// ID of the instance that researched the tech.
"ResearcherInstanceId": "int",
// Supply cost paid to research the tech.
"SupplyCost": "int",
// Energy cost paid to research the tech.
"EnergyCost": "int",
// Whether the tech was researched by the player or the scenario.
"ProvidedByScenario": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "TechResearched"
}
//
// UnitControlTransferred Event
//
// This event is fired when control of a unit is transferred from a player to another
// player.
//
{
// Index of the player that lost control of the unit.
"OldPlayerIndex": "int",
// Index of the player that gained control of the unit.
"NewPlayerIndex": "int",
// ID that indicates the type of the unit that was transferred. Units are available via
// the Metadata API as Game Objects.
"SquadId": "string",
// ID of the instance that was transferred.
"InstanceId": "int",
// ID of the instance that caused the transfer of the unit, if appropriate; otherwise,
// 0.
"CapturerInstanceId": "int",
// Location of the unit when control was transferred.
"Location": {
"x": "double",
"y": "double",
"z": "double"
},
// Population consumed by the transferred unit.
"PopulationCost": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "UnitControlTransferred"
}
//
// UnitPromoted Event
//
// This event is fired when a unit is promoted.
//
{
// Index of the player that controls the unit that was promoted.
"PlayerIndex": "int",
// ID that indicates the type of the unit that was promoted. Units are available via
// the Metadata API as Game Objects.
"SquadId": "string",
// ID of the instance that was promoted.
"InstanceId": "int",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "UnitPromoted"
}
//
// UnitTrained Event
//
// This event is fired for the following reasons:
// - A player trains a unit from a building.
// - A unit is produced by a leader power or card.
// - A unit is provided by the scenario (for instance, the units a player starts with
// at the beginning of the scenario).
//
{
// Index of the player that controls the unit that was trained.
"PlayerIndex": "int",
// ID that indicates the type of the unit that was trained. Units are available via the
// Metadata API as Game Objects.
"SquadId": "string",
// Instance ID that identifies the unit. The unit will be referred to by this ID in
// subsequent events.
"InstanceId": "int",
// ID of the instance that trained the unit, if appropriate; otherwise, 0.
"CreatorInstanceId": "int",
// Location of the unit when it spawned.
"SpawnLocation": {
"x": "double",
"y": "double",
"z": "double"
},
// Supply cost paid to train the unit.
"SupplyCost": "int",
// Energy cost paid to train the unit.
"EnergyCost": "int",
// Population cost paid to train the unit.
"PopulationCost": "int",
// Whether the unit that was trained was cloned by a leader power.
"IsClone": "bool",
// Whether the unit was trained by the player or the scenario.
"ProvidedByScenario": "bool",
// Elapsed time, measured in milliseconds, since the point when the match started.
"TimeSinceStartMilliseconds": "int",
// Name of the event.
"EventName": "UnitTrained"
}
404 Not Found
The specified Match could not be found.
Representations
500 Internal Server Error
Internal Server Error
Representations
503 Service Unavailable
Service Unavailable
Representations
Code samples
@ECHO OFF
curl -v -X GET "https://www.haloapi.com/stats/hw2/matches/{matchId}/events"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://www.haloapi.com/stats/hw2/matches/{matchId}/events?" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://www.haloapi.com/stats/hw2/matches/{matchId}/events");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.ajax({
url: "https://www.haloapi.com/stats/hw2/matches/{matchId}/events?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "GET",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://www.haloapi.com/stats/hw2/matches/{matchId}/events";
NSArray* array = @[
// Request parameters
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://www.haloapi.com/stats/hw2/matches/{matchId}/events');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('www.haloapi.com')
conn.request("GET", "/stats/hw2/matches/{matchId}/events?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('www.haloapi.com')
conn.request("GET", "/stats/hw2/matches/{matchId}/events?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://www.haloapi.com/stats/hw2/matches/{matchId}/events')
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body