d2pt.js is a Node.js scraper for Dota 2 Pro Tracker, focused on hero meta and per-hero statistics.
- 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+
npm install d2pt.js
# or
yarn add d2pt.js
# or
pnpm add d2pt.jsCreate 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();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βtruefor the most-played role
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 nameratingβ 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.
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));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 |
Made with π and JavaScript.
This project is not affiliated with Dota 2 Pro Tracker.