Giter Site home page Giter Site logo

owapi's Introduction

OW API

Donate to keep OWAPI alive

This server is a simple way to get read-only information about player statistics in the game Overwatch by Blizzard.

A live version runs on https://owapi.net.

Game data

This API does not aim to expose data about the heroes, maps, etc in the game. For that, use https://github.com/jamesmcfadden/overwatch-api.

API Docs

OWAPI has a very simple RESTful API to get information.
As the API is read-only, the only method required is GET.

See the doc for more information.

Running an instance

OWAPI has a few requirements:

  • A Python version >3.6
  • Probably a Linux-based server; I don't know about the viability of running it on Windows.

Installation steps:

  1. Clone the repository.

    git clone https://github.com/Fuyukai/OWAPI.git

  2. Setup a Redis server.

    Redis should be running on the default port - 6379. You can override this in config.yml; however. Redis is used for caching lots of data so that there's not a 10 second delay on EVERY request as the data is fetched and scraped; it is essential.

    For Debian/Ubuntu, you can install one with: sudo apt install redis-server

    You can enable it with: sudo systemctl enable redis-server && sudo systemctl start redis-server.

  3. Install the requirements.

    For debian-based systems, run this first: sudo apt install libxslt-dev python3-dev python3-venv build-essential zlib1g-dev pkg-config

    Install poetry packaging and dependency manager by following the installation documentation.

    To set up the virtualenv: poetry install

  4. Copy and tweak the example config file.

    cp config.example.yml config.yml

  5. Start the OWAPI server.

    PYTHONPATH=. poetry run asphalt run config.yml

    The server is now running on http://localhost:4444/

    Note: If you want the full speedups from Kyoukai you must run with uvloop enabled: PYTHONPATH=. poetry run asphalt run -l uvloop config.yml

owapi's People

Contributors

andrewzah avatar avaren avatar doezer avatar downy avatar endbug avatar fuyukai avatar jkroepke avatar jpylypiw avatar js41637 avatar leofidus avatar mikevb1 avatar nabijaczleweli avatar pree avatar pyup-bot avatar relaera avatar shaneisley avatar tirril29 avatar tklie avatar verath avatar zerefel avatar zeroparticle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owapi's Issues

[owapi.net/api/v2] ...heroes/:heroname region force does not work?

I have tried some requests with players playing on both EU and US, it seems that when it comes to hero specific data on v2, forcing region=us does not work anymore and I get EU data (with many 'no hero data found' probably 0min played for some heroes in some game modes on EU).

UTF-8 Decode Issue

Running

http://localhost:4444/api/v2/u/Dad-12262/stats/general

gives me this error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/kyokai/app.py", line 326, in delegate_request
    response = await route.invoke(self, ctx)
  File "/usr/local/lib/python3.5/site-packages/kyokai/route.py", line 92, in invoke
    result = await self._wrapped_coro(ctx, *matches)
  File ".../OWAPI/owapi/util.py", line 53, in res
    result = await func(ctx, *args)
  File ".../OWAPI/owapi/routes.py", line 144, in bl_get_stats
    platform=ctx.request.values.get("platform", "pc"))
  File ".../OWAPI/owapi/blizz_interface.py", line 88, in region_helper
    page = await get_user_page(ctx, battletag, platform, reg, extra)
  File ".../OWAPI/owapi/blizz_interface.py", line 59, in get_user_page
    page_body = await get_page_body(ctx, built_url, cache_time=cache_time)
  File ".../Python/OWAPI/owapi/blizz_interface.py", line 36, in get_page_body
    result = await util.with_cache(ctx, _real_get_body, url, expires=cache_time)
  File ".../OWAPI/owapi/util.py", line 36, in with_cache
    result = await func(ctx, *args)
  File ".../OWAPI/owapi/blizz_interface.py", line 34, in _real_get_body
    return (await req.read()).decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

0x8b being โ€น according to here.

Returns Win rates Higher than 100%

Example Output for Matt-15211 at Heroes General

{
  "battletag": "Matt-15211",
  "_request": {
    "route": "/api/v2/u/Matt-15211/heroes/general",
    "api_ver": 2
  },
  "region": "us",
  "heroes": {
    "symmetra": 0.6333333333333333,
    "reinhardt": 2,
    "bastion": 0.7,
    "winston": 0.4,
    "pharah": 5,
    "lucio": 2,
    "soldier76": 3,
    "tracer": 8,
    "mercy": 0.65,
    "junkrat": 7,
    "mei": 6,
    "roadhog": 0.45,
    "mccree": 1,
    "zarya": 0.7666666666666667,
    "dva": 0.5833333333333334,
    "zenyatta": 1,
    "genji": 0.85,
    "hanzo": 3,
    "ana": 0.7833333333333333,
    "reaper": 0.7666666666666667,
    "torbjorn": 0.43333333333333335,
    "widowmaker": 1
  }
}

I took a look at the overwatch page. Tracer appears to be listing 0 games played, but that doesn't make sense given your code says to return 0 in that case. This may not be an issue with your code though is the point I'm making. I tested a couple other bots and they show 0 games played too for some reason. It doesn't seem to be a you problem, but I'll open it and you can decide what to do. At the least, not returning 0 seems like a problem.

MO player page changed

Hi there,

Just to let you know, I think the player profile page on MO just changed as OWAPI is now tracebacking on the /v1/u/(.*)/heroes route.

My guess is that they removed the total number of played games from the top stats (win/less, win rate, ranking, ...)

$ curl localhost:4444/api/v1/u/SunDwarf-21353/stats                                                                                                                                                                                                                                                            
Traceback (most recent call last):
  File "/data/perso/OWAPI/venv/lib/python3.5/site-packages/kyokai/app.py", line 281, in delegate_request
    response = await coro.invoke(ctx)
  File "/data/perso/OWAPI/venv/lib/python3.5/site-packages/kyokai/route.py", line 90, in invoke
    result = await self._wrapped_coro(ctx, *matches)
  File "/data/perso/OWAPI/owapi/util.py", line 48, in res
    result = await func(ctx, *args)
  File "/data/perso/OWAPI/owapi/routes.py", line 147, in get_stats
    built_dict["overall_stats"]["rank"] = int(ov_stats[0].text[1:].replace(",", ""))
ValueError: invalid literal for int() with base 10: '                                    40/41                                '

I didn't have the time to look at it myself yet.

Regards.

Root redirect is broken

https://owapi.net/

redirects to

https://owapi.net/https%3A//github.com/SunDwarf/OWAPI/blob/master/api.md

Breaking change: Times are now floats

Any time values are now float values in the /v2 responses.

They are all in _hours_.

As this is a breaking change, I'm holding off on updating the live version for a bit.

v3 Hero stats giving "s76" and "soldier76"

These are returned at [REGION]["heroes"]["stats"]["quickplay"/"competitive"]["s76"/"soldier76"]

Can be found in quickplay and competitive stats, s76 and soldier76 have the exact same stats, just in different keys.

Checked the divs after posting this. This seems intentional, as dva comes up as d.va as well. I guess this can be closed if this is for backwards compatibility or whatever.

API v3

So I'm gonna be making a v3 to fix some issues v2 has (notably the region issues and the comp/qp split).

(No, I'm not retiring v2 (yet)).

I'm looking on opinions on what to split and what to unify:

  • Comp and quickplay together (i.e {"competitive": ..., "quickplay": ...})
  • Heroes and other stats together

Basically, if it should be a giant JSON blob (easier) or multiple routes (pls senpai nginx can only take so much on an Atom).

Can I retri

Can I retrieve competetive stats?
Can I get stats for different maps?

How to install?

Hi @SunDwarf how i can install this? there's a guide to do it?

Regards!

No support for xbox/psn

xbox/psn as ?platform= does not work as it will still ass for a battle tag please fix this issue!

Level doesn't count reset

Hey, the level output doesn't count the reset that the player made if he past 100 levels.
So the API doesn't show correctly players above level 100.

Suggestion; add the player's level to the API.

Heyo.
It'd be neat if the API would return a given user's level in Overwatch. Right now I'm parsing the MasterOverwatch website myself for the user's level, but it'd be great if this data could come straight from the API.

Document v3 Routes

New routes need documenting.

  • Blob
  • Stats
  • Heroes
  • Changes to regions
  • Changes to format

Can't get ur Json response from JQuery Ajax Call : "Get No 'Access-Control-Allow-Origin' header is present on the requested resource"

Hello, i tryed our Overwatch API and it work great. Nice job.
But when i tryed to import it into my web site, to add some content on the page, i get
"No 'Access-Control-Allow-Origin' header is present on the requested resource". There is my code :
"
$.ajax({
url: "http://owapi.net/api/v2/u/Neo-21849/stats/competitive",
type: 'GET',
crossDomain: true,
dataType: 'json',
success: function() { alert("Success"); },
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
},function(data){
console.log(data);
});
".

If you have any idea to figure it out, it will be awesome ! :)

Heroes API method does not work

Method provided in doc

$ http GET "https://owapi.net/api/v1/u/SunDwarf-21353/heroes"

doesn't work (getting error 500) on any account. I saw v2 method but its not implemented yet...
p.s. thank you for great api !

Installation instructions

The installation instructions on this package are failing on VM's I'm running (Debian Testing and Ubuntu 16.04).
Both VM's are running Python 3.5.2 and seem to fail to have ./venv/activate, which resides in venv/bin/activate. Running that file, it seems to install some things, but yet still does not compile, as it doesn't install every requirement.

I strongly suggest to make a better documentation, so other users can run this too on own computers / VM's.

Server Down

just was trying to get stats and looks like your server is down :(

Installation issues

Hi,

Looking forward to trying this out - having a few issues running it though.

I've spun up a server with Ubuntu 14.04 and clones the repo but it doesn't seem to want to run. Installing from requirements.txt seems to miss Asphalt too.

What setup are you using and what version of Python should be used?

Competitive heroes time played

Currently when you request /heroes it get's time played from quick play only. I'd love to see /competitive switch or just adding them together

Bad URL requests hang forever

For example, localhost:4444/xapi/v2/u/Dad-12262/stats/general or
localhost:4444/api/v0/u/Dad-12262/heroes.

Console Log:

2016-08-05 13:01:07,923 - [INFO] OWAPI -> Started OWAPI server.
2016-08-05 13:01:17,291 - [INFO] Kyokai -> HTTP/1.1 GET /xapi/v2/u/Dad-12262/stats/general - 404
2016-08-05 13:01:17,298 - [ERROR] asyncio -> Task exception was never retrieved
future: <Task finished coro=<Kyoukai.delegate_request() done, defined at /usr/local/lib/python3.5/site-packages/kyoukai/app.py:316> exception=AttributeError("'NoneType' object has no attribute 'groups'",)>
Traceback (most recent call last):
  File "uvloop/task.pyx", line 126, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:97501)
  File "/usr/local/lib/python3.5/site-packages/kyoukai/app.py", line 352, in delegate_request
    await self.handle_http_error(fof, protocol, ctx)
  File "/usr/local/lib/python3.5/site-packages/kyoukai/app.py", line 303, in handle_http_error
    resp = wrap_response(await error_handler.invoke(ctx))
  File "/usr/local/lib/python3.5/site-packages/kyoukai/route.py", line 108, in invoke
    matches = self.matcher.fullmatch(ctx.request.path).groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Not sure if this is more OWAPI or Kyoukai related.
Possible solutions: Redirect malformed requests somewhere, or return a general error.

v3/blob returns null for all regions

http://localhost:4444/api/v3/u/Aurelius-1648/blob

Actually every v3 route returns the following:

Output:

{
    "_request": {
        "api_ver": 3,
        "route": "/api/v3/u/Aurelius-1648/blob"
    },
    "eu": null,
    "kr": null,
    "any": null,
    "us": null
}

Adding a region param returns 404

User avatar

Would you consider adding support to get the user's avatar? Thanks

Make all responses JSON

Currently, if the battle tag is valid, the content type of the response is application/json. Whereas if the battle tag is invalid, the content type of the response is text/plain. Is it possible for all responses to be JSON?

On a side note, really appreciate your work!

Edit: Or could you allow requests with headers to set Content-Type: application/json?

Currently erroring for people who have played new Comp

While I am sure this is only a temporary thing. API is currently erroring because Overwatch is currently not returning the amount of games played which is causing problemos.

Should be able to fix it by doing something like

g = game_box.xpath(".//text()[. = 'Games Played']/../..")
if not g:
    games, losses, wr = None, None, None
else:
    games = int(g[0][1].text.replace(",", ""))
    losses = games - wins
    wr = floor((wins / games) * 100)

Set 'Access-Control-Allow-Origin' in header

Firstly, thanks for your work.

I'm currently building a platform and I will use your project to get overwatch stats.

I got a little problem by a simple get call from my web app in ReactJS : No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

Do you know how to set headers to : 'Access-Control-Allow-Origin' in asphat or kyoukai ?

Thx.

Round or truncate floating point values

Example from https://owapi.net/api/v2/u/LittleJediWolf/stats/general?platform=xbl

"objective_time_avg": 0.006944444444444445,
"time_spent_on_fire_avg": 0.005277777777777778,
"time_spent_on_fire_most_in_game": 0.12555555555555556,

Maybe 3-4 decimal places?

/api/v1/u/:battletag/heroes/:id returns empty array

{

    "_request": {
        "api_ver": 1,
        "route": "/api/v1/u/SunDwarf-21353/heroes/11"
    },
    "stats": [ ],
    "battletag": "SunDwarf-21353",
    "region": "eu"

}
{

    "_request": {
        "api_ver": 1,
        "route": "/api/v1/u/Dad-12262/heroes/11"
    },
    "stats": [ ],
    "battletag": "Dad-12262",
    "region": "us"
}

API returns old results again?

Another issue here.
The /stats endpoint seems to return the old stats again, from MasterOverwatch instead of blizzard.
Am I slowly going insane or is it actually returning the wrong results?

Live version down.

Whether or not this belongs here I don't know, but I've been using the live version succesfully for a while now with no issues, until today. All I can get from it are 500 errors whenever I attempt to request anything from it.

Player profiles sometimes return 404 and can work fine again some minutes later

Hi,

I am using the API for a TeamSpeak 3 plugin of mine to show player statistics in the client.

While testing my code I found that sometimes a player profile can suddenly return a 404 and be back to normal again just some minutes later.

For example just some minutes ago this profile: https://owapi.net/api/v2/u/Sigi-2686/stats/general returned a standard 404 response of the API:

{"region": null, "msg": "profile not found", "_request": {"route": "/api/v2/u/Sigi-2686/stats/general", "api_ver": 2}, "error": 404}

Now (some minutes have passed) the same profile is back to normal and returns the JSON data as expected.
I don't think that it is related only to certain profiles but it can happen to any profile occasionally.
So far it has happend very occasionally to some random profiles that I was testing during the day.

Player level bug

Player level received for players above level 100 seem to be only the last 2 digits.

E.g. Using this player tape2#1581 who has a level of 275. Response received is "level": 75,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.