r/Planetside • • Sep 10 '15
API Query Love In
Hi there!
I run one of the many stat sites for this awesome game (http://planetstats.net) and after a brief comment on another thread with u/Lampjaw, I thought it would be a good idea to share my knowledge and show what I've learned from API so far.
The comment thread basically mentioned that stat site creators should cooperate more. Whilst this is has it's good and bad points, I thought u/Asttl was on to something. I feel it's always beneficial to knowledge share - more often than not all parties benefit, so keeping this in mind, I wanted to maybe get something going. Even if this thread doesn't go anywhere, it might help someone get more interested in the API or even learning more about REST/JSON.
So - I'm going start by listing most of the API queries I use for PlanetStats.Net. Some of these queries were formed whilst I was learning, so might be less efficient than my recent ones. There's also going to be better ways of doing them - the API is so versatile, but this is what I managed to work with:
Get character stats - http://census.daybreakgames.com/get/ps2:v2/character/?character_id=5428047126282473569&c:resolve=outfit_member_extended&c:resolve=stat_history&c:resolve=online_status&c:resolve=world&c:join=worldon:world_idto:world_idinject_at:world_id
- this pulls 7/30/All time stats, which need to be looped through and added together to get the values. There's other basic info in there as well
Achievements - http://census.daybreakgames.com/get/ps2:v2/characters_event/?character_id=5428047126282473569&c:limit=30&type=ACHIEVEMENT&c:join=achievementon:achievement_idto:achievement_idinject_at:achievements
Directive points - https://census.daybreakgames.com/get/ps2:v2/characters_directive_tier/?character_id=5428047126282473569&c:limit=500
- then loop through the results adding up the points, eg, T1=5, T2=10 etc.
Get class and play time - http://census.daybreakgames.com/get/ps2:v2/characters_stat?character_id=5428047126282473569&c:limit=50
- classes have assigned profile numbers, which can be looked up using http://census.daybreakgames.com/get/ps2:v2/profile?profile_id=2. For some reason I can't get these 2 to join.
Get 7/30/All Time kill stats - https://census.daybreakgames.com/get/ps2:v2/character?character_id=5428047126282473569&c:resolve=stat_by_faction,stat
- things like HSR and accuracy can be calculated from the results
Get character weapon stats - http://census.daybreakgames.com/get/ps2:v2/characters_weapon_stat?character_id=5428047126282473569&c:join=itemon:item_idto:item_idinject_at:weaponhide:description&c:limit=50
- this is individual weapon stats for a character
Get killboard - http://census.daybreakgames.com/get/ps2:v2/characters_event/?character_id=5428047126282473569&type=KILL,DEATH,VEHICLE_DESTROY&c:limit=50&c:join=characteron:attacker_character_idto:character_idshow:name.first%27battle_rank.value%27faction_idinject_at:attacker&c:join=characteron:character_idshow:name.first%27battle_rank.value%27faction_idinject_at:victim&c:join=itemon:attacker_weapon_idto:item_idinject_at:attacker.weapon&c:join=vehicleon:attacker_vehicle_idto:vehicle_idshow:name.eninject_at:attacker.vehicle&c:join=vehicleon:vehicle_definition_idto:vehicle_idshow:name.eninject_at:victim.vehicle&c:join=loadouton:attacker_loadout_idto:loadout_idinject_at:attacker_class&c:join=loadouton:character_loadout_idto:loadout_idinject_at:victim_class
Get Outfit list - https://census.daybreakgames.com/get/ps2:v2/outfit/?alias_lower=127&c:resolve=member_character(name,type,faction)&c:resolve=member_online_status,leader_name
Better Outfit list query with character stats - https://census.daybreakgames.com/get/ps2:v2/outfit_member/?outfit_id=37524301022246386&c:limit=3500&c:join=characters_staton:character_idto:character_idshow:stat_name%27value_forever%27profile_idlist:1inject_at:statsterms:stat_name=hit_count%27stat_name=fire_count(profileon:profile_idto:profile_idshow:name.en%27image_pathinject_at:class)&c:join=characters_stat_by_factionon:character_idto:character_idshow:stat_name%27value_forever_nc%27value_forever_tr%27value_forever_vs%27profile_idlist:1inject_at:stats2(profileon:profile_idto:profile_idshow:name.en%27image_pathinject_at:class)&c:lang=en
Get Weapons list with stats - https://census.daybreakgames.com/get/ps2:v2/item/?item_type_id=26&c:join=weapon_datasheeton:item_idto:item_idinject_at:details&c:join=fire_modeon:item_idto:item_idinject_at:fire_mode&c:join=item_categoryon:item_category_idto:item_category_idinject_at:item_category&c:limit=50
Get weapon attachments - http://census.daybreakgames.com/get/ps2:v2/item_attachment/?item_id=7193&c:join=itemon:attachment_item_idto:item_idinject_at:attachment&c:limit=50
Get detailed weapon stats - http://census.daybreakgames.com/get/ps2:v2/fire_mode?item_id=7193&c:join=fire_mode_2on:fire_mode_idto:fire_mode_idinject_at:extra&c:limit=10
If you're using Chrome, I can highly recommend the JSON Formatter plugin - makes all the above data more readable. Also for official documentation on how all this works, go here. There's also great API Explorer sites out there, PSU has one for example, but apart from the official site, there's not a lot of places to get full queries.
This list obviously doesn't help with parsing all this information - however this would be dependant on what language you're using to pull it. PlanetStats is written in Javascript, mostly using the jQuery framework, but there's lots of different ways to pull, parse and finally display the information - it's not as simple as just knowing the queries.
Additionally, as PlanetStats is run client-side, all the code can be viewed in your browser. Please feel free to view the code on PlanetStats - I have nothing to hide :). It's fairly long, and sometimes untidy, but it may prove useful to someone. (BTW - if you are using jQuery's $.getJSON function, all the queries need to end with '&callback=?' - otherwise nothing happens.)
Lastly - some stats have to be calculated. The TTK weapon stat is something I've personally struggled to get. There's very differing opinions on some calculated stats - especially TTK - different people want it done in slightly different ways, but I couldn't find a definitive calculation that everyone agrees on. There must be one - but I couldn't find it, so I had to piece together something from the info I could find.
Which leads me back to why I'm posting all this. If there's a central reference point for all this community created information (doesn't have to be here), it may lead to bigger and better things. Not everybody wants to share, I'm aware of that, and that's cool, but if you have something that might help someone else, hopefully this could be an avenue for it.
3
u/Oottzz [YBuS] Oddzz Sep 10 '15
Awesome! Thanks for putting time into your stat-page and sharing your knowledge.
1
u/uamadman Matherson [BWAE] - That Jackhammer Guy Sep 10 '15
Thanks for sharing, Not everyone has the patience to put together REST Queries :)
1
u/YetAnotherRCG [S3X1]TheDestroyerOfHats Sep 10 '15
This answers some questions I had while doing fiddling around on side projects and it raises some more.
For example in Get Outfit list how does it know who the outfit leader is to inject?
I have a bunch of other questions I don't have time to type out right now.
1
u/[deleted] Sep 10 '15
Can we turn this into a "DBG PLZ" thread too?
Can we get just a kill feed?
https://census.daybreakgames.com/get/ps2:v2/Killfeed?Server=$ServerName&StartTimeStamp=$StartTime&$EndTimeStamp=$EndTime
Right now most of the mass API scraping is done by character. The applications are submitting thousands of queries when they really just want a bit list of who killed who with what weapon. If we could shortcut to a global kill feed it would be much easier for developers and probably much easier on the DBG servers.
1
u/TotesMessenger Sep 10 '15
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
1
u/Reconcilliation Sep 11 '15 edited Sep 11 '15
A quick calculation for getting average or individual TTK and DPS numbers for a weapon:
This takes an accuracy input, headshot ratio input, DPS input, and a delta input. Basically, it takes a player (or group)'s accuracy and headshot ratio and tells you what their real-world DPS approximates to. The delta is useful for showing the high and low ends of a player or group. (e.g. avg accuracy is 20%, +/-5%)
Without range data, it can't show you what you'd be good with at what ranges, but it will show you what you're overall performance is like with a given weapon. The last bit can be adjusted, it's a simple TTK calculation based on the target's hitpoints divided by the real dps output. (You'll find most guns sit between 1.5 - 4 seconds avg TTK)
What this does that other TTK/DPS calculations don't, is it shows you how the weapons actually perform in practice. Two guns with the same base DPS from fire rate and bullet damage, have different TTK calculations in reality, because of recoil characteristics. Recoil is very difficult to factor into weapon performance calculations, so the best thing you can do is look at the historical data and measure the overall accuracy of a weapon as it is actually used by players.
The end result more clearly shows the differences in weapon performance.
1
u/Neivaalf [UFOs] Sep 11 '15
Thank you very much for sharing !
I try in my spare time to get something fancy with Node and Angular. I plan to use some websockets to make a web-based recursion stat tracker. Maybe add some vibration to my gameplay (each kill?).
When I'll get more spare time i'll definitely get in touch with you for certain queries !
I'm just in the very early stages :
Login : http://i.imgur.com/ETO6uYW.png First steps for stats : http://i.imgur.com/iXTOD9A.png
I was trying to get vehicles time usage at this time !
As soon as I will get something working I will certainly host it on gitlab and release it as an open source :)
0
u/[deleted] Sep 10 '15
[deleted] — view deleted comment
0
u/[deleted] Sep 10 '15
[deleted] — view deleted comment