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 🙏

© 2026 – Pkg Stats / Ryan Hefner

opendota-sdk

v0.2.0

Published

Type-safe TypeScript SDK for the OpenDota API

Downloads

25

Readme

opendota-sdk

Type-safe TypeScript SDK for the OpenDota API.

npm version license

Table of Contents


Installation

npm install opendota-sdk
# pnpm add opendota-sdk
# bun add opendota-sdk

Quick Start

import { OpenDota } from "opendota-sdk";

const client = new OpenDota();

// Get match data
const { data: match, rateLimit } = await client.matches.get(7000000000);
console.log(match.duration, match.radiant_win);
console.log(`${rateLimit.remainingMinute} requests left this minute`);

// Get player info
const { data: player } = await client.players.get(76561198049899734);

// Search players
const { data: results } = await client.search.players({ q: "Dendi" });

Available Resources

client.matches

| Method | Description | |--------|-------------| | get(matchId) | Get match data by ID |

client.players

| Method | Description | |--------|-------------| | get(accountId) | Get player profile | | getWinLoss(accountId) | Get win/loss record | | getRecentMatches(accountId, params?) | Get recent matches |

client.heroes

| Method | Description | |--------|-------------| | list() | List all heroes |

client.heroStats

| Method | Description | |--------|-------------| | list() | Get aggregated hero stats |

client.search

| Method | Description | |--------|-------------| | players(params) | Search for players |

client.explorer

| Method | Description | |--------|-------------| | query(sql) | Run SQL queries against match data |

client.request

| Method | Description | |--------|-------------| | submit(matchId) | Request a match parse (costs 10 rate limit units) |

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | — | OpenDota API key | | baseUrl | string | https://api.opendota.com/api | API base URL | | maxRetries | number | 3 | Max retries for 429/5xx | | retryBaseDelay | number | 1000 | Base delay (ms) for backoff | | timeout | number | 30000 | Request timeout (ms) | | fetch | typeof fetch | globalThis.fetch | Custom fetch implementation |

Error Handling

All errors throw typed subclasses:

import { OpenDota, OpenDotaRateLimitError, OpenDotaNotFoundError } from "opendota-sdk";

try {
  const { data } = await client.matches.get(999999999);
} catch (error) {
  if (error instanceof OpenDotaNotFoundError) {
    console.log("Match not found");
  } else if (error instanceof OpenDotaRateLimitError) {
    console.log(`Rate limited. Remaining: ${error.remainingMinute}`);
  }
}

| Error Class | HTTP Status | Cause | |-------------|-------------|-------| | OpenDotaNotFoundError | 404 | Match/player doesn't exist | | OpenDotaRateLimitError | 429 | Exceeded request limit | | OpenDotaServerError | 5xx | OpenDota server issue | | OpenDotaError | — | Base error class |

Request Cancellation

const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);

const { data } = await client.matches.get(12345, {
  signal: controller.signal,
});

Rate Limits

Without API key: 60 requests/minute, 2,000/day.
With API key: 300 requests/minute, unlimited daily.

Get a free key at opendota.com/api-keys.

Every response includes rate limit metadata:

const { data, rateLimit } = await client.heroes.list();
console.log(rateLimit.remainingMinute); // e.g. 58
console.log(rateLimit.remainingDay);    // e.g. 1995 (null with API key)

Contributing

See CONTRIBUTING.md. Run tests with npm test.

License

MIT