Skip to content

Commit

Permalink
Add player information method
Browse files Browse the repository at this point in the history
Update README
  • Loading branch information
ShaunLWM committed Apr 21, 2019
1 parent 53afc69 commit f1ab7a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# overwatchleague.js
[!["Latest Release"](https://img.shields.io/github/release/ShaunLWM/OverwatchLeague.js.svg)](https://github.com/ShaunLWM/OverwatchLeague.js/releases/latest)
[!["Latest Release"](https://img.shields.io/npm/v/overwatchleague.js.svg)](https://github.com/ShaunLWM/OverwatchLeague.js/releases/latest)
[![MIT license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ShaunLWM/OverwatchLeague.js/blob/master/LICENSE)

OverwatchLeague API. Inspired by [blizzard.js](https://github.com/benweier/blizzard.js) and [OWLeagueLib](https://github.com/overtools/OWLeagueLib/).

## Install
Expand Down Expand Up @@ -28,10 +32,17 @@ OWL.getSchedule().then(response => {
console.log(response.data);
});
```
or the async way (node v8 and above)
```javascript
(async () => {
let players = await OWL.getPlayers();
console.log(players);
});
```
## Methods
- `getAppData`- Retrieve current app information
- `getSchedule` - Retrieve upcoming matches' schedule
- `getLiveStreams` - Retrieve live streams
- `getLiveStreams` - Retrieve current live streams
- `getMatch(id)` - Get match's information
- `getMatchStats(mapId, mapNumber)` - Get map information for particular match. [Example](https://api.overwatchleague.com/stats/matches/10528/maps/1): where `10528` is the `matchId` and `1` is the `mapNumber`
- `getTeam(id)` - Get team's information
Expand All @@ -42,5 +53,6 @@ OWL.getSchedule().then(response => {
- `getStandings` - Retrieve team standings (division info, player info, etc)
- `getVideos` - Retrieve VODs
- `getPlayers` - Get overall players' stats
- `getPlayer(id)` - Get player id's information
- `getUpcomingLiveMatches` - Get upcoming live matches
- `getMaps` - Get all maps in pool
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var axios = require('axios');
var axios = require("axios");
var OverwatchLeague = function OverwatchLeague() {
this.axios = axios.create({
baseURL: 'https://api.overwatchleague.com/',
baseURL: "https://api.overwatchleague.com/",
});
};

OverwatchLeague.prototype.getAppData = function fetchToken(origin, params) {
return this.axios.get('about');
return this.axios.get("about");
};

OverwatchLeague.prototype.getSchedule = function () {
return this.axios.get('schedule');
return this.axios.get("schedule");
};

OverwatchLeague.prototype.getLiveStreams = function () {
return this.axios.get('streams');
return this.axios.get("streams");
};

OverwatchLeague.prototype.getMatch = function (id) {
Expand All @@ -30,39 +30,43 @@ OverwatchLeague.prototype.getTeams = function () {
};

OverwatchLeague.prototype.getNews = function () {
return this.axios.get('news');
return this.axios.get("news");
};

OverwatchLeague.prototype.getPlaylistVideos = function (name) { // todo: are we the app?
return this.axios.get(`playlist/${name}`);
};

OverwatchLeague.prototype.getRankings = function () {
return this.axios.get('ranking');
return this.axios.get("ranking");
};

OverwatchLeague.prototype.getStandings = function () {
return this.axios.get('standings');
return this.axios.get("standings");
};

OverwatchLeague.prototype.getVideos = function () {
return this.axios.get('vods');
return this.axios.get("vods");
};

OverwatchLeague.prototype.getMatchStats = function (matchId, mapNumber) {
return this.axios.get(`stats/matches/${matchId}/maps/${mapNumber}`);
};

OverwatchLeague.prototype.getPlayers = function () {
return this.axios.get('stats/players');
return this.axios.get("stats/players");
};

OverwatchLeague.prototype.getPlayer = function (id) {
return this.axios.get(`players/${id}?expand=stats,stats.ranks`);
};

OverwatchLeague.prototype.getUpcomingLiveMatches = function () {
return this.axios.get('live-match?expand=team.content&locale=en-us');
return this.axios.get("live-match?expand=team.content&locale=en-us");
};

OverwatchLeague.prototype.getMaps = function () {
return this.axios.get('maps');
return this.axios.get("maps");
};

module.exports = new OverwatchLeague();
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"author": "Shaun (https://github.com/shaunidiot)",
"author": "Shaun (https://github.com/ShaunLWM)",
"name": "overwatchleague.js",
"description": "A Node.js library for the OverwatchLeague API",
"version": "0.0.2",
"homepage": "https://github.com/shaunidiot/OverwatchLeague.js",
"version": "0.0.3",
"homepage": "https://github.com/ShaunLWM/OverwatchLeague.js",
"license": "MIT",
"keywords": [
"blizzard",
Expand All @@ -16,10 +16,10 @@
],
"repository": {
"type": "git",
"url": "git://github.com/shaunidiot/OverwatchLeague.js.git"
"url": "git://github.com/ShaunLWM/OverwatchLeague.js.git"
},
"bugs": {
"url": "https://github.com/shaunidiot/OverwatchLeague.js/issues"
"url": "https://github.com/ShaunLWM/OverwatchLeague.js/issues"
},
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit f1ab7a1

Please sign in to comment.