Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hltv-personal-custom

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hltv-personal-custom

The unofficial HLTV Node.js API

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Dependency Status devDependencies Status

HLTV logo
The unofficial HLTV Node.js API

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. Each method has the number of requests it makes to HLTV documented in this README. This is important if you want to implement some kind of throttling yourself.

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
loadPage(url: string) => Promise<string>based 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 scorebot websocket
const myHLTV = HLTV.createInstance({ loadPage: (url) => axios.get(url) })
// or
const myHLTV = HLTV.createInstance({ loadPage: (url) => fetch(url) })
// or you can just use the HLTV export directly to use the default settings
import HLTV from 'hltv'

HLTV.getMatch({ ... })

See config schema

API

getMatch

Parses most information from a match page (1 request)

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

See schema


getMatches

Parses all matches from the hltv.org/matches/ page (1 request)

OptionTypeDefault ValueDescription
eventIdnumber?-Filter matches by event ID.
eventTypeMatchEventType?-Filter matches by event type.
filterMatchFilter?-Filter matches by pre-set categories. Overrides other filters.
HLTV.getMatches().then((res) => {
  ...
})

See schema

getMatchesStats

Parses all matches from the hltv.org/stats/matches page (1 request per page of results)

OptionTypeDefault ValueDescription
startDatestring?--
endDatestring?--
matchTypeMatchType?--
mapsGameMap[]?--
rankingFilterRankingFilter?--
delayBetweenPageRequestsnumber?0Used to prevent CloudFlare throttling (ms)
// ! BE CAREFUL, THIS CAN MAKE A LOT OF REQUESTS IF THERE ARE A LOT OF PAGES
HLTV.getMatchesStats({ startDate: '2017-07-10', endDate: '2017-07-18' }).then((res) => {
  ...
})

See schema


getMatchStats

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

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

See schema


getMatchMapStats

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

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

See schema


getStreams

Parses all streams present on the front page of HLTV (1 request + 1 request per stream if loadLinks is true)

OptionTypeDefault ValueDescription
loadLinksbooleanfalseEnables parsing of the stream links (every stream is an additional separate request).
HLTV.getStreams().then((res) => {
  ...
})

See schema


getRecentThreads

Parses the latest threads on the front page of HLTV (1 request)

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

See schema

getTeamRanking

Parses the info from the hltv.org/ranking/teams/ page (1 request)

OptionTypeDefault ValueDescription
year2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021--
month'january' | 'february' | 'march' | 'april' | 'may' | 'june' | 'july' | 'august' | 'september' | 'october' | 'november' | 'december'--
daynumber?--
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 (1 request)

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

See schema


getTeamByName

Same as getTeam but accepts a team name instead of ID. (2 requests)

OptionTypeDefault valueDescription
namestring-The team name
HLTV.getTeamByName({ name: "BIG" }).then(res => {
    ...
})

See getTeam schema


getTeamStats

Parses the info from the hltv.org/stats/teams/* page (4 requests + 1 more if currentRosterOnly is true)

OptionTypeDefault valueDescription
idnumber-The team id
currentRosterOnlyboolean?falseReturn stats about the current roster only
startDatestring?--
endDatestring?--
matchTypeMatchType?--
rankingFilterRankingFilter?--
mapsGameMap[]?--
bestOfXBestOfFilter?--
HLTV.getTeamStats({ id: 6137 }).then(res => {
    ...
})

See schema


getPlayer

Parses the info from the hltv.org/player/* page (1 request)

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. (2 requests)

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

See getPlayer schema

getPlayerStats

Parses the info from hltv.org/stats/players/* (3 requests)

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

See schema


getPlayerRanking

Parses the info from hltv.org/stats/players page (1 request)

OptionTypeDefault valueDescription
startDatestring?--
endDatestring?--
matchTypeMatchType?--
rankingFilterRankingFilter?--
mapsGameMap[]?--
minMapCountnumber?--
countriesstring[]--
bestOfXBestOfFilter?--
// 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 (1 request)

OptionTypeDefault valueDescription
eventTypeEventType?-Event type e.g. EventSize.Major, EventSize.LocalLAN
prizePoolMinnumber?-Minimum prize pool (USD$)
prizePoolMaxnumber?-Maximum prize pool (USD$)
attendingTeamIdsnumber[]?--
attendingPlayerIdsnumber[]?--
HLTV.getEvents().then(res => {
    ...
})

See schema


getEvent

Parses the info from the hltv.org/event/ page (1 request)

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

See schema


getEventByName

Same as getEvent but accepts a event name instead of ID. (2 requests)

OptionTypeDefault valueDescription
namestring-The event name
HLTV.getEventByName({ name: "IEM Katowice 2019" }).then(res => {
    ...
})

See getEvent schema


getPastEvents

Parses the info from the hltv.org/events/archive page (1 request per page of results)

OptionTypeDefault valueDescription
eventTypeEventType?-Event type e.g. EventSize.Major, EventSize.LocalLAN
startDatestring?--
endDatestring?--
prizePoolMinnumber?-Minimum prize pool (USD$)
prizePoolMaxnumber?-Maximum prize pool (USD$)
attendingTeamIdsnumber[]?--
attendingPlayerIdsnumber[]?--
delayBetweenPageRequestsnumber?0Used to prevent CloudFlare throttling (ms)
// ! BE CAREFUL, THIS CAN MAKE A LOT OF REQUESTS IF THERE ARE A LOT OF PAGES
HLTV.getPastEvents({ startDate: '2019-01-01', endDate: '2019-01-10' }).then(res => {
    ...
})

See schema


getResults

Parses the info from the hltv.org/results page (1 request per page of results)

OptionTypeDefault valueDescription
startDatestring?--
endDatestring?--
matchTypeResultMatchType?--
rankingFilterRankingFilter?--
mapsGameMap[]?--
countriesstring[]--
bestOfXBestOfFilter?--
contentFiltersContentFilter?--
eventIdsnumber[]?--
playerIdsnumber[]?--
teamIdsnumber[]?--
gameGameType?--
delayBetweenPageRequestsnumber?0Used to prevent CloudFlare throttling (ms)
// ! BE CAREFUL, THIS CAN MAKE A LOT OF REQUESTS IF THERE ARE A LOT OF PAGES
HLTV.getResults({ eventIds: [1617], bestOfX: [BestOfFilter.BO3] }).then(res => {
    ...
})

See schema

getNews

Parses the info from the hltv.org/news/archive/ page (1 request)

OptionTypeDefault ValueDescription
year2005 | 2006 | 2007 | 2008 | 2009 | 2010 | 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021-If you specify a year you must specify a month as well
month'january' | 'february' | 'march' | 'april' | 'may' | 'june' | 'july' | 'august' | 'september' | 'october' | 'november' | 'december'-If you specify a month you must specify a year as well
eventIdsnumber[]?--
// If you don't provide a filter the latest news will be parsed
HLTV.getNews()
HLTV.getNews({ eventIds: [3491] })
HLTV.getNews({ year: 2020, month: 'may' }).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


TEAM_PLACEHOLDER_IMAGE
HLTV.TEAM_PLACEHOLDER_IMAGE
// https://www.hltv.org/img/static/team/placeholder.svg

PLAYER_PLACEHOLDER_IMAGE
HLTV.PLAYER_PLACEHOLDER_IMAGE
// https://static.hltv.org/images/playerprofile/bodyshot/unknown.png

Keywords

FAQs

Package last updated on 25 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc