Skip to content

gbrlstr/d2pt.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

d2pt.js

πŸ“ƒ About

d2pt.js is a Node.js scraper for Dota 2 Pro Tracker, focused on hero meta and per-hero statistics.

Features

  • Hero meta β€” ranking by position (Carry, Mid, Offlane, Support)
  • Hero info β€” matches, win rate, and most-played role for a specific hero

Requirement: Node.js 18+


Installation

npm install d2pt.js
# or
yarn add d2pt.js
# or
pnpm add d2pt.js

Quick start

Create an instance and use the methods (all return a Promise):

const { D2PtScraper } = require("d2pt.js");
// ESM: import { D2PtScraper } from "d2pt.js";

const d2pt = new D2PtScraper();

getHeroInfo(heroName) β€” hero information

Returns hero stats by role (All Roles, Carry, Mid, Offlane, Support, Hard Support): matches, win rate, and which role is most played.

const heroInfo = await d2pt.getHeroInfo("Anti-Mage");
console.log(heroInfo);

Example response:

[
  {
    "role": "All Roles",
    "matches": "5339",
    "winRate": "49%",
    "mostPlayed": false
  },
  {
    "role": " Carry",
    "matches": "4948",
    "winRate": "49%",
    "mostPlayed": true
  },
  {
    "role": " Mid",
    "matches": "219",
    "winRate": "42%",
    "mostPlayed": false
  }
]
  • role β€” position (All Roles, Carry, Mid, Offlane, Support, Hard Support)
  • matches β€” number of matches (string)
  • winRate β€” win rate (e.g. "49%")
  • mostPlayed β€” true for the most-played role

getHeroesMeta(category, max_result?) β€” meta heroes by position

Returns the list of meta heroes for a category.
Categories: "hc" (Carry), "mid", "off", "sup4", "sup5", "pos4", "pos5", "All", "Carry", "Mid", "Off".

// Top 3 carries in meta
const heroes = await d2pt.getHeroesMeta("hc", 3);
console.log(heroes);

Example response:

[
  {
    "name": "Clinkz",
    "rating": "3851",
    "matches": "5759",
    "winRate": "55.0%",
    "contestRate": "44.1%",
    "radiantWinRate": "58.2%",
    "direWinRate": "51.8%"
  },
  {
    "name": "Slark",
    "rating": "3398",
    "matches": "7717",
    "winRate": "52.1%",
    "contestRate": "46.0%",
    "radiantWinRate": "55.8%",
    "direWinRate": "48.2%"
  },
  {
    "name": "Drow Ranger",
    "rating": "3383",
    "matches": "4569",
    "winRate": "53.1%",
    "contestRate": "26.0%",
    "radiantWinRate": "56.8%",
    "direWinRate": "49.3%"
  }
]
  • name β€” hero name
  • rating β€” rating (string)
  • matches β€” matches (string)
  • winRate β€” win rate (e.g. "55.0%")
  • contestRate β€” contest rate (e.g. "44.1%")
  • radiantWinRate / direWinRate β€” win rate per side

max_result is optional; default is 10.


Full example (async/await)

const { D2PtScraper } = require("d2pt.js");

async function main() {
  const d2pt = new D2PtScraper();

  const heroInfo = await d2pt.getHeroInfo("Anti-Mage");
  console.log("Hero info:", heroInfo);

  const topCarries = await d2pt.getHeroesMeta("hc", 5);
  console.log("Top 5 carries:", topCarries);
}

main().catch(console.error);

With then/catch:

d2pt
  .getHeroesMeta("mid", 5)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

Development

git clone <repo>
cd d2pt.js
npm install
Command Description
npm run build Clean and compile (outputs to lib/)
npm run example Run example using built lib/
npm run example:hero Hero-only example (ts-node)
npm run example:meta Meta-only example (ts-node)
npm run test Run tests (Jest)
npm run watch Build in watch mode

πŸ’° Support the project

BuyMeACoffee


πŸ‘·β€β™‚οΈ Creator

Contributors

Twitter Twitch

Made with πŸ’– and JavaScript.

License

MIT

This project is not affiliated with Dota 2 Pro Tracker.

About

πŸ“¦ A Minimalistic Node.js DOTA PRO TRACKER SCRAPER

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors