This is my experimental project, but also small useful module for node.js which helps you to easy implement data from popular CS:GO website hltv.org.
$ npm install hltv-api
- Using CommonJS module:
const express = require('express');
const HLTV = require('hltv-api');
const app = express();
app.get('/', function(req, res) {
HLTV.getNews(function(news) {
return res.json(news);
});
});
app.get('/results', function(req, res) {
HLTV.getResults(function(results) {
return res.json(results);
});
});
app.get('/all-matches', function(req, res) {
HLTV.getAllMatches(function(stats) {
return res.json(stats);
});
});
app.get('/:matchId(*)', function(req, res) {
HLTV.getMatches(req.params.matchId, function(stats) {
return res.json(stats);
});
});
app.listen(3000, function() {
console.log('Listening on port 3000...');
});
- Using babel and necessary plugins (demo app)
import {
getNews,
getResults,
getMatches,
} from 'hltv-api';
app.get('/', (req, res) => {
getNews(news => res.json(news));
});
- request
http://localhost:3000/
- response
[{
"title": "ESL Pro League Season 5 Finals preview",
"description": "The next big offline event, the ESL Pro League Season 5 Finals, is kicking off tomorrow, May 30, with the round-robin group stage. We have put together a preview where we delve into each of the 12 teams taking part in the $750,000 tournament.",
"link": "https://www.hltv.org/news/20567/esl-pro-league-season-5-finals-preview",
"date": "Mon, 29 May 2017 23:27:00 GMT"
}, ]
app.get('/results', (req, res) => {
getResults(results => res.json(results));
});
- request
http://localhost:3000/results
- response
[{
"event": "ECS Season 4 Europe",
"maps": "trn",
"team1": {
"name": "fnatic",
"crest": "https://static.hltv.org/images/team/logo/4991",
"result": 13
},
"team2": {
"name": "FaZe",
"crest": "https://static.hltv.org/images/team/logo/6667",
"result": 16
},
"matchId": "/matches/2316387/fnatic-vs-faze-ecs-season-4-europe"
}, ]
app.get('/all-matches', (req, res) => {
getMatches((stats) => res.json(stats));
});
- request
http://localhost:3000/all-matches
- response
[{
"id": 2336543,
"link": "/matches/2336543/yalla-vs-ez5-extremesland-2019-middle-regional-finals",
"time": "2019-09-27T14:40:00.000Z",
"event": {
"name": "eXTREMESLAND 2019 Middle Regional Finals",
"crest": "https://static.hltv.org/images/eventLogos/4927.png"
},
"stars": 0,
"map": "Inferno",
"teams": [
{
"name":"Yalla",
"crest":"https://static.hltv.org/images/team/logo/8280"
},
{
"name":"EZ5",
"crest":"https://static.hltv.org/images/team/logo/10395"
}
]
}, ]
app.get('/:matchId(*)', (req, res) => {
const { matchId } = req.params;
getMatches(matchId, (stats) => res.json(stats));
});
- request
http://localhost:3000/2316387
Or
http://localhost:3000/matches/2316387/fnatic-vs-faze-ecs-season-4-europe
- response
[{
"playerName": "Robin flusha Rönnquist",
"playerId": "/player/3055/flusha",
"kills": 19,
"deaths": 19,
"plusMinus": 0,
"adr": 73.7,
"kast": 62.1,
"rating": 0.97
}, ]