alfg / overwatch-api

:earth_americas: An Unofficial Overwatch HTTP API
https://owapi.io/docs/
MIT License
148 stars 27 forks source link

Requesting PSN/XBL stats #50

Closed hardcorshik closed 6 years ago

hardcorshik commented 6 years ago

So, getting profiles from PC works fine with Platform/Region/BattleTag. But there's no Battletag for PS and Xbox. So how do I get the stats for that? I tried

let platform = 'psn'; let region = 'us'; let tag = '<insert psn name here>']; var profile;

OverwatchApi.getProfile(platform, region, tag, (err, json) => { if (err) { console.error(err); } else { let username = json.username; let level = json.level; let rank = json.competitive.rank;

but it didn't give back the results

alfg commented 6 years ago

Hi @HaRDCoRSHiK31,

Try using region as global and their xbl or psn username as the battletag. Let me know if that works.

If not, can you provide an xbl or psn user I can use to test?

Thanks!

hardcorshik commented 6 years ago

Alright, I tried it, but it failed still.

I used platform: psn region: global tag: DrollestMaple03

alfg commented 6 years ago

Hi @HaRDCoRSHiK31,

I tried the following:

const overwatch = require('overwatch-api');

const platform = 'psn';
const region = 'global';
const tag = 'Drollestmaple03';

overwatch.getProfile(platform, region, tag, (err, json) => {
    console.log(err, json);
});

and i got back results:

{
  "username": "Drollestmaple03",
  "level": 50,
  "portrait": "https://assets.webn.mobi/overwatch/e140608ce5aced2bf91234f2b67330e77de36915b5353fe1b98f9544fc2ea198.png",
  "endorsement": {
    "sportsmanship": {
      "rate": null
    },
    "shotcaller": {
      "rate": null
    },
    "teammate": {
      "rate": null
    },
    "level": 1,
    "frame": "https://d3hmvhl7ru3t12.cloudfront.net/svg/icons/endorsement-frames-be58f32488898c106f2ad8b1c3012dbce42d19b758c4b18bf2afbe91fc8f1d2cc83a0de433321792ff0fb3a1f66d37ded31598bd538838b30fa4537db617926e.svg#_1",
    "icon": "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQwIiB3aWR0aD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxjaXJjbGUgcj0iMTUuOTE1NDk0MzA5MTg5NTQiIGZpbGw9IiMyYTJiMmUiIHN0cm9rZS1kYXNoYXJyYXk9IjAgMTAwIiBzdHJva2UtZGFzaG9mZnNldD0iMjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlPSIjZjE5NTEyIiBjeD0iNTAlIiBjeT0iNTAlIj48L2NpcmNsZT48Y2lyY2xlIHI9IjE1LjkxNTQ5NDMwOTE4OTU0IiBmaWxsPSJ0cmFuc3BhcmVudCIgc3Ryb2tlLWRhc2hhcnJheT0iMCAxMDAiIHN0cm9rZS1kYXNob2Zmc2V0PSIxMjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlPSIjYzgxYWY1IiBjeD0iNTAlIiBjeT0iNTAlIj48L2NpcmNsZT48Y2lyY2xlIHI9IjE1LjkxNTQ5NDMwOTE4OTU0IiBmaWxsPSJ0cmFuc3BhcmVudCIgc3Ryb2tlLWRhc2hhcnJheT0iMCAxMDAiIHN0cm9rZS1kYXNob2Zmc2V0PSIxMjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlPSIjNDBjZTQ0IiBjeD0iNTAlIiBjeT0iNTAlIj48L2NpcmNsZT48dGV4dCB4PSI1MCUiIHk9IjUwJSIgZHk9Ii4zZW0iIGZvbnQtZmFtaWx5PSJjZW50dXJ5IGdvdGhpYyxhcmlhbCxzYW5zLXNlcmlmIiBmb250LXdlaWdodD0iMzAwIiBmb250LXNpemU9IjE2IiBzdHJva2U9IiNmNmY2ZjYiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0iI2Y2ZjZmNiIgdGV4dC1hbmNob3I9Im1pZGRsZSI+MTwvdGV4dD48L3N2Zz4="
  },
  "private": true,
  "games": {
    "quickplay": {
      "won": null
    },
    "competitive": {
      "won": null,
      "lost": null,
      "draw": 0,
      "played": null,
      "win_rate": null
    }
  },
  "playtime": {},
  "competitive": {
    "rank": null,
    "rank_img": null
  },
  "levelFrame": "https://d1u1mce87gyfbn.cloudfront.net/game/playerlevelrewards/0x025000000000091C_Border.png",
  "star": ""
}

I'm also getting results back from: http://ow-api.herokuapp.com/profile/psn/global/Drollestmaple03

Although, since the account is private, not all stats will be returned.

hardcorshik commented 6 years ago

Thank you, fixed the issue by updating to a newer version.