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

@sashke-er/hltv

v2.15.14

Published

The unofficial HLTV Node.js API

Downloads

502

Readme

Dependency Status devDependencies Status

Table of contents

Installation

NPM

Usage

:warning: WARNING: Abusing this library will likely result in an IP ban from HLTV simply because of Cloudflare bot protection.

       Please use with caution and try to limit the rate and amount of your requests if you value your access to HLTV.

import HLTV from 'hltv'
// Or if you're stuck with CommonJS
const { HLTV } = require('hltv')

Configuration

You can create an instance of HLTV with a custom config if you want to.

const myHLTV = HLTV.createInstance({hltvUrl: /* my-proxy-server */, loadPage: /* my custom request library */})

See config schema

API

getMatch

Parses most information from a match page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | The match id

HLTV.getMatch({id: 2306295}).then(res => {
    ...
})

See schema


getMatches

Parses all matches from the hltv.org/matches/ page

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | - | - | - | - |

HLTV.getMatches().then((res) => {
  ...
})

See schema for Live Matches

See schema for Upcoming Matches


getMatchesStats

Parses all matches from the hltv.org/stats/matches page

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | startDate | string? | - | - | | endDate | string? | - | - | | matchType | MatchType? | - | - | | maps | Map[]? | - | - |

HLTV.getMatchesStats({startDate: '2017-07-10', endDate: '2017-07-18'}).then((res) => {
  ...
})

See schema


getMatchStats

Parses info from the all maps stats page (hltv.org/stats/matches/*/*)

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | id | number | - | - |

HLTV.getMatchStats({id: 62979}).then((res) => {
  ...
})

See schema


getMatchMapStats

Parses info from the single map stats page (hltv.org/stats/matches/mapstatsid/*/*)

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | id | number | - | - |

HLTV.getMatchMapStats({id: 49968}).then((res) => {
  ...
})

See schema


getResults

Parses all matches from the hltv.org/results/ page

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| pages | number | 1 | Number of pages with results to be parsed | teamID | number? | - | ID of specific team | eventID | number? | - | ID of specific event |

// Note: if you pass `eventID` to getResults you cannot pass a `pages` parameter
// since HLTV doesn't have pages for the event filter.
HLTV.getResults({pages: 2}).then((res) => {
  ...
})

See schema


getStreams

Parses all streams present on the front page of HLTV

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| loadLinks | boolean | false | Enables parsing of the stream links. Its an option since it can slow down the response (every stream is a separate request).

HLTV.getStreams().then((res) => {
  ...
})

See schema


getRecentThreads

Parses the latest threads on the front page of HLTV

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | - | - | - | - |

HLTV.getRecentThreads().then((res) => {
  ...
})

See schema

getTeamRanking

Parses the info from the hltv.org/ranking/teams/ page

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | year | string | - | - | | month | string | - | Must be lowercase and in MMMM format | | day | string | - | - | | country | string | - | Must be capitalized ('Brazil', 'France' etc)

// If you don't provide a filter the latest ranking will be parsed
HLTV.getTeamRanking()
HLTV.getTeamRanking({country: 'Thailand'})
HLTV.getTeamRanking({year: '2017', month: 'may', day: '29'}).then((res) => {
  ...
})

See schema


getTeam

Parses the info from the hltv.org/team/ page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | The team id

HLTV.getTeam({id: 6137}).then(res => {
    ...
})

See schema


getTeamStats

Parses the info from the hltv.org/stats/teams/ page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | The team id

HLTV.getTeamStats({id: 6137}).then(res => {
    ...
})

See schema


getPlayer

Parses the info from the hltv.org/player/ page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | The player id

HLTV.getPlayer({id: 6137}).then(res => {
    ...
})

See schema


getPlayerStats

Parses the info from hltv.org/stats/players/*

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | - | startDate | string | - | - | endDate | string | - | - | matchType | MatchType? | - | - | rankingFilter | RankingFilter? | - | - |

HLTV.getPlayerStats({id: 7998}).then(res => {
    ...
})

See schema


getPlayerRanking

Parses the info from hltv.org/stats/players page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| startDate | string | - | - | endDate | string | - | - | matchType | MatchType? | - | - | rankingFilter | RankingFilter? | - | - |

// If you don't provide a filter the latest ranking will be parsed
HLTV.getPlayerRanking({startDate: '2018-07-01', endDate: '2018-10-01'}).then(res => {
    ...
})

See schema


getEvents

Parses the info from the hltv.org/events page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| size | EventSize?? | - | Event size type. (EventSize.Small, EventSize.Big). Default (empty) combines both.

HLTV.getEvents().then(res => {
    ...
})

See schema


getEvent

Parses the info from the hltv.org/event/ page

Option | Type | Default value | Description | :---:|:---:|:---:|:---:| id | number | - | The event id

HLTV.getEvent({id: 3389}).then(res => {
    ...
})

See schema


connectToScorebot

Presents an interface to receive data when the HLTV scorebot updates

NOTE: While connectToScorebot returns a Promise, the promise will never resolve. Instead you should pass the callbacks described below.

Option | Type | Default Value | Description | :---:|:---:|:---:|:---:| | id | number | - | The match ID | | onScoreboardUpdate | function? | - | Callback that is called when there is new scoreboard data | | onLogUpdate | function? | - | Callback that is called when there is new game log data | | onFullLogUpdate | function? | - | It's still unclear when this is called and with what data, if you find out please let me know! | onConnect | function? | - | Callback that is called when a connection with the scorebot is established | | onDisconnect | function? | - | Callback that is called when the scorebot disconnects |

HLTV.connectToScorebot({id: 2311609, onScoreboardUpdate: (data) => {
    ...
}, onLogUpdate: (data) => {
    ...
}})

The onLogUpdate callback is passed an LogUpdate object

The onScoreboardUpdate callback is passed an ScoreboardUpdate object