npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dota2libp

v0.1.2

Published

a node api for dota2 with promise

Downloads

18

Readme

#About

a node promise api for dota2

Get steam key

click this, http://steamcommunity.com/dev/apikey, login with your Steam account and get the unique key.

Installation

npm install dota2libp --save

Usage

use in your node source:

var api = require('dota2libp');

Initialization

var dota2api = new api('your key')

Api

getMatchHistory(opt)

get a list of matches played.

Available Options
var config {
  hero_id: < id > , // Search for matches with a specific hero being played (hero ID, not name, see HEROES below)
  game_mode: < mode > , // Search for matches of a given mode (see below)
  skill: < skill > , // 0 for fany, 1 for normal, 2 for high, 3 for very high skill (default is 0)
  min_players: < count > , // the minimum number of players required in the match
  account_id: < id > , // Search for all matches for the given user (32-bit or 64-bit steam ID)
  league_id: < id > , // matches for a particular league
  start_at_match_id: < id > , // Start the search at the indicated match id, descending
  matches_requested: < n > , // Maximum is 25 matches (default is 25)
  tournament_games_only: < string > // set to only show tournament games
}
var config = {
    account_id : '125997846'
};
dota2api.getMatchHistory(config).then(function(matchData){
    console.log(matchData);
})

#####Result Field Format:

  • num_results - the number of results contained in this response
  • total_results - the total number of results for this particular query [(total_results / num_results) = total_num_pages]
  • results_remaining - the number of results left for this query [(results_remaining / num_results) = remaining_num_pages]
  • matches - an array of num_results matches:
    • match_id - the numeric match ID
    • match_seq_num - the match's sequence number - the order in which matches are recorded
    • start_time - date in UTC seconds since Jan 1, 1970 (unix time format)
    • lobby_type - the type of lobby
      • see: https://github.com/kronusme/dota2-ap...a/lobbies.json
    • players - an array of players:
      • account_id - the player's 32-bit Steam ID - will be set to "4294967295" if the player has set their account to private.
      • player_slot - an 8-bit unsigned int: if the left-most bit is set, the player was on dire. the two right-most bits represent the player slot (0-4).
      • hero_id - the numeric ID of the hero that the player used (see below).

getMatchDetails(opt)

to get detailed information about a specific match.

Available options:
var config={
  match_id=<id> // the match's ID
}
 dota2api.getMatchDetails(config).then(function(details){
    console.log(details); 
 })

getHeroes(opt)

Used to get an UP-TO-DATE list of heroes.

Available Options
var config={
  // nothing ...
  language:'en' // you can also set language just for this request
  format : 'XML' // you can also set format just for this request
}
Result Field Format:
  • heroes - an array of the heroes:
    • name - the hero's in-game "code name"
    • id - the hero's numeric ID
    • localized_name - the hero's text name (language specific result - this field is not present if no language is specified)
  • count - the total number of heroes in the list
 dota2api.getHeroes(config).then(function(data){
      // you will get the result
      console.log(data);
  })

getLeagueListing(opt)

Used to get a list of the tournament leagues that are available for viewing in the client (i.e. you can buy a ticket to them). Intended for use in conjunction with GetLiveLeagueGames.

Available Options
var config={
  // nothing ...
  language:'en' // you can also set language just for this request
  format : 'XML' // you can also set format just for this request
}
 dota2api.getLeagueListing(config).then(function(data) {
      // you will get the result
      console.log(data);
  })

getLiveLeagueGames(opt)

Used to get a list of the tournament leagues that are available for viewing in the client (i.e. you can buy a ticket to them). Intended for use in conjunction with GetLiveLeagueGames.

#####Available Options

Common options only (see above) - Note that if no language is specified, the API will return the in-game "string" placeholders for all fields marked with (language specific).

 dota2api.getLiveLeagueGames(config).then(function(data) {
      // you will get the result
      console.log(data);
  })
Result Field Format:
  • leagues - an array of the leagues:
    • name - the league's full name (language specific)
    • leagueid - the league's numeric ID
    • escription - a description of the leauge (language specific)
    • tournament_url - the url of the tournament's home page

getMatchHistoryBySequenceNum(opt,callback)

Used to get the matches in the order which they were recorded (i.e. sorted ascending by match_seq_num). This means that the first match on the first page of results returned by the call will be the very first public mm-match recorded in the stats.

var config={
  start_at_match_seq_num:<id>,
  matches_requested:<n>
}
dota2api.getMatchHistoryBySequenceNum(config.then(function(data) {
      // you will get the result
      console.log(data);
  })