How do I get a unit name from its Squad-Id (HW2)

I know you’re supposed to be able to retrieve the ‘Game Objects’ with the meta data api but it doesn’t seem to contain everything. For example I did a Ctrl-F for “unsc_inf_generic_marine” (the SquadId for marines in deathmatch) on the entire string returned and I got 0 results so how can I possibly get the name?
This is the same for some other units so what is the best way to get the display name from the SquadId?
Thanks :slight_smile:

Also in Match Results you can get total number built and destroyed of each unit type from each player however instead of being like
‘Unit’:{
‘Name’:[name]
‘Builit’:[#]
‘Lost’:[#]
}

it’s more like
‘[name]’:{
‘Builit’:[#]
‘Lost’:[#]
}

which means that you have to have a separate class for every single unit type instead of just one global ‘unit’ class (that’s right isn’t it?)
So is there somewhere which just has a list of all the names for classes that I need because other wise I’ve got to some how create a game where every unit was built so I can get it from that.

Thanks again :slight_smile:

> 2533274842284695;1:
> I know you’re supposed to be able to retrieve the ‘Game Objects’ with the meta data api but it doesn’t seem to contain everything. For example I did a Ctrl-F for “unsc_inf_generic_marine” (the SquadId for marines in deathmatch) on the entire string returned and I got 0 results so how can I possibly get the name?
> This is the same for some other units so what is the best way to get the display name from the SquadId?
> Thanks :slight_smile:

The ‘game objects’ endpoint is limited to returning only 100 items at once. There are currently 232 game objects available. This can be seen in the response in the Paging.TotalCount property. To get anything more than the first 100, you need to specify the ‘startAt’ parameter when making your request (see below).

> 2533274842284695;1:
> Also in Match Results you can get total number built and destroyed of each unit type from each player however instead of being like
> ‘Unit’:{
> ‘Name’:[name]‘Builit’:[#]‘Lost’:[#]}
>
> it’s more like
> ‘[name]’:{
> ‘Builit’:[#]‘Lost’:[#]}
>
> which means that you have to have a separate class for every single unit type instead of just one global ‘unit’ class (that’s right isn’t it?)
> So is there somewhere which just has a list of all the names for classes that I need because other wise I’ve got to some how create a game where every unit was built so I can get it from that.
>
> Thanks again :slight_smile:

What are you using to deserialize your response data? If you’re using JSON.NET you can do the following to map an array of unknown property names to known objects:

> public Dictionary<string, UnitStat> UnitStats { get; set; }

This means you will have a dictionary of UnitStats accessible through dictionary keys.

I’m currently working on updating HaloSharp to support Halo Wars 2 which might makes things a lot easier for you to start getting the data you want.

> 2753093343646559;2:
> > 2533274842284695;1:
> > I know you’re supposed to be able to retrieve the ‘Game Objects’ with the meta data api but it doesn’t seem to contain everything. For example I did a Ctrl-F for “unsc_inf_generic_marine” (the SquadId for marines in deathmatch) on the entire string returned and I got 0 results so how can I possibly get the name?
> > This is the same for some other units so what is the best way to get the display name from the SquadId?
> > Thanks :slight_smile:
>
> The ‘game objects’ endpoint is limited to returning only 100 items at once. There are currently 232 game objects available. This can be seen in the response in the Paging.TotalCount property. To get anything more than the first 100, you need to specify the ‘startAt’ parameter when making your request (see below).
>
>
> - https://www.haloapi.com/metadata/hw2/game-objects?startAt=0 - https://www.haloapi.com/metadata/hw2/game-objects?startAt=100 (I can see the ‘<em>unsc_inf_generic_marine</em>’ object in this request.) - https://www.haloapi.com/metadata/hw2/game-objects?startAt=200
>
> > 2533274842284695;1:
> > Also in Match Results you can get total number built and destroyed of each unit type from each player however instead of being like
> > ‘Unit’:{
> > ‘Name’:[name]‘Builit’:[#]‘Lost’:[#]}
> >
> > it’s more like
> > ‘[name]’:{
> > ‘Builit’:[#]‘Lost’:[#]}
> >
> > which means that you have to have a separate class for every single unit type instead of just one global ‘unit’ class (that’s right isn’t it?)
> > So is there somewhere which just has a list of all the names for classes that I need because other wise I’ve got to some how create a game where every unit was built so I can get it from that.
> >
> > Thanks again :slight_smile:
>
> What are you using to deserialize your response data? If you’re using JSON.NET you can do the following to map an array of unknown property names to known objects:
>
>
>
>
> > public Dictionary<string, UnitStat> UnitStats { get; set; }
>
> This means you will have a dictionary of UnitStats accessible through dictionary keys.
>
> I’m currently working on updating HaloSharp to support Halo Wars 2 which might makes things a lot easier for you to start getting the data you want.

Thanks for all this, makes sense now.
I am using Newtonsoft (that’s JSON.NET right?) to deserialise it so I will take a look at dictionaries- thanks :slight_smile: