dinubs / HLTV

The unofficial HLTV Node.js API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dependency Status devDependencies Status

pyarray logo
The unofficial HLTV Node.js API

#Table of contents

Installation

NPM

Usage

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

//create an object before using the API
const hltv = new HLTV()

API

getMatch

Parses most information from a match page

Option Type Default value Description
id int - The match id
hltv.getMatch({id: 2306295}).then(res => {
    ...
})

Results in an object with the following schema:

Property Type Note
team1 string
team1Id int
team2 string
team2Id int
date string e.g. "12th of November 2016 22:30"
format string
additionalInfo string e.g. "* Grand final"
event object Object schema: {name: string, link: string}
maps [objects] Object schema: {map: string, result: string}
streams [objects] Object schema: {name: string, link: string}
highlights array
players array
title string Mainly used when the teams are still unknown (e.g. "iBP Masters Grand Final")

getMatches

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

Option Type Default Value Description
- - - -
hltv.getMatches().then((res) => {
  ...
})

Results in an array of objects with the following schema:

Property Type Note
time string Will be undefined if the match is live or finished
team1 string
team1Id int
team2 string
team2Id int
map string Only exists if the match is BO1
format string
label string Mainly used when the teams are still unknown (e.g. "iBP Masters Grand Final")
id int
eventId int
live boolean
finished boolean

getLatestResults

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

Option Type Default Value Description
pages int 1 Number of pages with results to be parsed
hltv.getLatestResults({pages: 2}).then((res) => {
  ...
})

Results in an array of objects with the following schema:

Property Type Note
result string e.g. "2 - 0" or "16 - 9"
team1 string
team1Id int
team2 string
team2Id int
map string Only exists if the match is BO1
format string
id string

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) => {
  ...
})

Results in an array of objects with the following schema:

Property Type Note
name string
category string e.g. "Caster" or "Female player"
country string An ISO 3166 code
hltvLink string
realLink string Only if the loadLinks flag is enabled
viewers int

getActiveThreads

Parses the latest threads on the front page of HLTV

Option Type Default Value Description
- - - -
hltv.getActiveThreads().then((res) => {
  ...
})

Results in an array of objects with the following schema:

Property Type Note
title string
link string
replies int

About

The unofficial HLTV Node.js API


Languages

Language:JavaScript 100.0%