jakejrichards / cod-api

A thin Call of Duty API wrapper written in TypeScript
MIT License
40 stars 6 forks source link

Api Call bo4? #7

Closed ShadowFM closed 5 years ago

ShadowFM commented 6 years ago

Hi! Is it possible to have also a api call for the stats from bo4 soon?

jakejrichards commented 6 years ago

More than likely call of duty will release some bo4 endpoints and I will be monitoring this. As soon as they are released I will add them to the list!

ShadowFM commented 6 years ago

Would be very cool!

luqmanyasin commented 6 years ago

Any news on this?

jakejrichards commented 6 years ago

Any news on this?

I suspect that they will more than likely have something for bo4 shortly after the game's release. As for now, though, I haven't seen anything.

luqmanyasin commented 6 years ago

Any news on this?

I suspect that they will more than likely have something for bo4 shortly after the game's release. As for now, though, I haven't seen anything.

Fair enough, thanks for the update!

gazreyn commented 5 years ago

Yeah I've been keeping an eye on it too. I wish their stuff was more immediate, pretty sure it takes an hour for stats to update or longer. Would love to make stream widgets for things like headshot count or match win counts etc

luqmanyasin commented 5 years ago

Found the new endpoint in case anyone is interested. @jakejrichards @gazreyn https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/psn/gamer/Lierrmm/profile/

jakejrichards commented 5 years ago

Found the new endpoint in case anyone is interested. @jakejrichards @gazreyn https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/psn/gamer/Lierrmm/profile/

Awesome! I'll get this in today

luqmanyasin commented 5 years ago

Perfect, just an FYI the PC platform attr value is "battle" and not "steam"

gazreyn commented 5 years ago

Hmm, regarding Battle.net, how do you format the username because username#1234 or username-1234 doesn't work

gazreyn commented 5 years ago

Nevermind I found it, you need to use %23 - username%231234

Although from what I can see, it's not actually returning any stats

streamgamelabels commented 5 years ago

Main problem I have is for instance weirdly formatted numbers: https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/psn/gamer/DooMTheRace/profile/

data->mp->lifetime->all->wins show as 8.3886804E7 And according to others using the API this number should be 781.

So anyone have an idea on how to convert the weird number to the real integer?

Best Regards Joakim

gazreyn commented 5 years ago

From what I can see it's giving a straight up int - 83886804

Unsure of how it's getting that value and if it could technically be converted some how. Might be a bug on their end? Although if you're saying another API/site is able to get the real value then it's weird

luqmanyasin commented 5 years ago

Looks like the decimal point is hex to prevent long int outputs. If you want a real int, just remove anything after the decimal point or convert the decimal point onwards using parseInt

streamgamelabels commented 5 years ago

I figured out a better way: wins = totalGamesPlayed - losses - ties Not as straightforward as accessing "wins" immediately. But gives results that don't need conversion.

streamgamelabels commented 5 years ago

Looks like the decimal point is hex to prevent long int outputs. If you want a real int, just remove anything after the decimal point or convert the decimal point onwards using parseInt

You don't happen to have a decent example of this based on the number 8.3889234E7? I can't seem to figure it out. The result is expected to be 3154

luqmanyasin commented 5 years ago

I was wrong it's a float, use floor to convert it

DonsWayo commented 5 years ago

someone can give me an example of getting the profile on pc of the bo4? , with battle.net username not return any data. Can get with in game-username?

gazreyn commented 5 years ago

If your battle.net handle was foobar#1234, the following would be the URL you use. However, I don't think they're pulling the data to their API yet, it shows a json structure but has no data.

https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/battle/gamer/foobar%231234/profile/

codykerns commented 5 years ago

@jakejrichards I opened up a PR to add Black Ops 4 support. #8

zsaraf commented 5 years ago

Has anyone figured out how to convert the E numbers to decimal numbers? I've tried almost everything (been going deep on Wolfram Alpha lol), and haven't found any way to convert. Any help here would be much appreciated!

gazreyn commented 5 years ago

Seems they're finally returning data now for Battle.net, for MP at least. Still no sign of Blackout stats. https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/battle/gamer/gazreyn%232546/profile/

DonsWayo commented 5 years ago

Did anyone get the leadeboards from the bo4?

trentbullard commented 5 years ago

the E numbers are just exponents most likely, e.g.

the usage of "mEn" would indicate a value of m × 10^n

from https://en.wikipedia.org/wiki/Scientific_notation

still no blackout stats

iAmAnoob2020 commented 5 years ago

hi, kinda late, ive been trying to use this API for BO4 for a few days now. i have the validation workin. But im stuck on how to grab certain information from the stats. like, just the value of the kills. im doing this in javascript BTW with node.js. any help would be nice, thanks

jakejrichards commented 5 years ago

@iAmAnoob2020 Could you provide an example from your code?

iAmAnoob2020 commented 5 years ago

@jakejrichards this is for a discord bot with node.js. it outputs the entire api response. request(https://bo4tracker.com/api/stats/bo4/${username}/${plat}, function(err, response, body){ if(err) console.log(err); if(body.includes("error")) return message.channel.send(<@${message.author.id}>, the user you have entered does not exist within the database! \n if you are doing this for Battle.net please do <user>%23<digits>); results = JSON.stringify(body); message.channel.send(results); });

Negativitet commented 5 years ago

Btw on the profile endpoint - just add ?type=blackout as ex. https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/psn/gamer/DooMTheRace/profile/?type=blackout and you get black out stats (the ones that are available atleast)

gazreyn commented 5 years ago

Thanks for that @Negativitet

sdoddler commented 5 years ago

does anyone know the other available ?types that @Negativitet mentioned? I'm trying to find weapon data but having no luck.. the tracker sites seem to have it..

streamgamelabels commented 5 years ago

@sdoddler from what I've gathered sofar weapon data will not have it's own ?type= it should be visible under each sub type

so just /profile should have the weapon stats for regular MP - but I also see that warzone (blackout) has been added as map/modes to that, but they contain no data.

Treyarch/Activision is still building on these endpoints, so until the stats actually appear on my.callofduty.com I don't think we can say for sure.

but ?type=blackout gives blackout and ?type=zombies seems to have zombie placeholders, haven't gotten around to check for actual data yet.

0n1dev commented 5 years ago

@jakejrichards @streamgamelabels How can i get blackout matches data? cod.tracker.gg and callofdutytracker.com get blackout matches data.

i try "https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/battle/gamer/jutes%2311766/matches/days/7/type/blackout" but fail.

gazreyn commented 5 years ago

@cimpdev it's a parameter so the URL should be https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/battle/gamer/jutes%2311766/matches/days/7?type=blackout

0n1dev commented 5 years ago

@gazreyn i try your link. but this data mp matches data. i wanna get blackout matches data

streamgamelabels commented 5 years ago

@cimpdev there are no matches stored in the API yet for blackout, what I (and cod.tracker and callofdutytracker) does is to simply check the lifetime changes at intervals and store what changed since last update. So if kills increased with 5 since last update, then we store that as a "match that got 5 kills"

gazreyn commented 5 years ago

@cimpdev Oh in which case use https://my.callofduty.com/api/papi-client/crm/cod/v2/title/bo4/platform/battle/gamer/jutes%2311766/profile?type=blackout

jakejrichards commented 5 years ago

Closing this as I have added -> https://github.com/jakejrichards/cod-api/commit/3644e1698fe3ef6c409e76e62687d1fe13638621