2.19.3 • Published 4 years ago

hltv-pro v2.19.3

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

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.

OptionTypeDefault valueDescription
hltvUrlstringhttps://www.hltv.orgUrl that will be used to construct requests to HLTV
hltvStaticUrlstringhttps://static.hltv.orgUrl that will be used to construct links to images
loadPagefunctionbased on the 'request' libraryFunction that will be called when the library makes a request to HLTV
httpAgentHttpAgentHttpsAgentHttp agent used when sending a request and connecting to the scoreboard websocket
const myHLTV = HLTV.createInstance({loadPage: (url) => axios.get(url)})
//or
const myHLTV = HLTV.createInstance({loadPage: (url) => fetch(url)})

See config schema

API

getMatch

Parses most information from a match page

OptionTypeDefault valueDescription
idnumber-The match id
HLTV.getMatch({id: 2306295}).then(res => {
    ...
})

See schema


getMatches

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

OptionTypeDefault ValueDescription
----
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

OptionTypeDefault ValueDescription
startDatestring?--
endDatestring?--
matchTypeMatchType?--
mapsMap[]?--
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/*/*)

OptionTypeDefault ValueDescription
idnumber--
HLTV.getMatchStats({id: 62979}).then((res) => {
  ...
})

See schema


getMatchMapStats

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

OptionTypeDefault ValueDescription
idnumber--
HLTV.getMatchMapStats({id: 49968}).then((res) => {
  ...
})

See schema


getResults

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

OptionTypeDefault ValueDescription
pagesnumber1Number of pages with results to be parsed
teamIDnumber?-ID of specific team
eventIDnumber?-ID of specific event
contentFiltersContentFilter[]?[]Add filter of the content
// 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

OptionTypeDefault ValueDescription
loadLinksbooleanfalseEnables 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

OptionTypeDefault ValueDescription
----
HLTV.getRecentThreads().then((res) => {
  ...
})

See schema

getTeamRanking

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

OptionTypeDefault ValueDescription
yearstring?--
monthstring?-Must be lowercase and in MMMM format
daystring?--
countrystring?-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

OptionTypeDefault valueDescription
idnumber-The team id
HLTV.getTeam({id: 6137}).then(res => {
    ...
})

See schema


getTeamStats

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

OptionTypeDefault valueDescription
idnumber-The team id
HLTV.getTeamStats({id: 6137}).then(res => {
    ...
})

See schema


getPlayer

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

OptionTypeDefault valueDescription
idnumber-The player id
HLTV.getPlayer({id: 6137}).then(res => {
    ...
})

See schema


getPlayerByName

Same as getPlayer but accepts a player name instead of ID.

OptionTypeDefault valueDescription
namestring-The player name
HLTV.getPlayerByName({name: "chrisJ"}).then(res => {
    ...
})

See getPlayer schema

getPlayerStats

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

OptionTypeDefault valueDescription
idnumber--
startDatestring--
endDatestring--
matchTypeMatchType?--
rankingFilterRankingFilter?--
HLTV.getPlayerStats({id: 7998}).then(res => {
    ...
})

See schema


getPlayerRanking

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

OptionTypeDefault valueDescription
startDatestring?--
endDatestring?--
matchTypeMatchType?--
rankingFilterRankingFilter?--
// 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

OptionTypeDefault valueDescription
sizeEventSize?-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

OptionTypeDefault valueDescription
idnumber-The event id
HLTV.getEvent({id: 3389}).then(res => {
    ...
})

See schema


connectToScorebot

Presents an interface to receive data when the HLTV scorebot updates

OptionTypeDefault ValueDescription
idnumber-The match ID
onScoreboardUpdatefunction?-Callback that is called when there is new scoreboard data
onLogUpdatefunction?-Callback that is called when there is new game log data
onFullLogUpdatefunction?-It's still unclear when this is called and with what data, if you find out please let me know!
onConnectfunction?-Callback that is called when a connection with the scorebot is established
onDisconnectfunction?-Callback that is called when the scorebot disconnects
HLTV.connectToScorebot({id: 2311609, onScoreboardUpdate: (data, done) => {
    // if you call done() the socket connection will close.
}, onLogUpdate: (data, done) => {
    ...
}})

The onLogUpdate callback is passed an LogUpdate object

The onScoreboardUpdate callback is passed an ScoreboardUpdate object

matches

matches/:id/-

results

events

events/:id/-

stats

stats/players

stats/teams

stats/matches

stats/events

stats/maps

stats/leaderboards

2.19.3

4 years ago

2.19.2

4 years ago

2.19.1

4 years ago