Giter Site home page Giter Site logo

thematlin / hltv-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dajk/hltv-api

0.0 0.0 0.0 742 KB

An unofficial JSON api for popular CS:GO website hltv.org. Check available methods on https://hltv-api.vercel.app/

Home Page: http://npm.im/hltv-api

License: MIT License

JavaScript 2.92% TypeScript 92.20% CSS 4.88%

hltv-api's Introduction

HLTV API

Build Status npm Codecov dependencies Status devDependencies Status

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.

Installation

$ npm install hltv-api

Methods

  1. getNews
  2. getResults
  3. getMatches
  4. getStatsByMatchId

Check all the available methods: https://hltv-api.vercel.app/

How to use

Simple API example
  • Using CommonJS module:
const HLTV = require('hltv-api').default
const express = require('express')
const app = express()

app.get('/', async (req, res) => {
  const news = await HLTV.getNews()
  res.json(news)
})

app.get('/results', async (req, res) => {
  const results = await HLTV.getResults()
  res.json(results)
})

app.get('/matches', async (req, res) => {
  const matches = await HLTV.getMatches()
  res.json(stats)
})

app.get('/:matchId(*)', async (req, res) => {
  const stats = await HLTV.getMatches(req.params.matchId)
  res.json(stats)
})

app.listen(3000, () => {
  console.log('Listening on port 3000...')
})
  • Using babel and necessary plugins (demo app)
import HLTV from 'hltv-api'
News
app.get('/', async (req, res) => {
  const news = await HLTV.getNews()
  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"
  }
]
Results
app.get('/results', async (req, res) => {
  const results = await HLTV.getResults()
  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"
  }
]
Matches
All Matches
app.get('/matches', async (req, res) => {
  const matches = await getMatches()
  res.json(stats)
})
  • request
http://localhost:3000/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"
      }
    ]
  }
]
Single Match
app.get('/:matchId(*)', async (req, res) => {
  const { matchId } = req.params
  const stats = await getMatches(matchId)
  res.json(stats)
})
  • request
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
  }
]

hltv-api's People

Contributors

dajk avatar dependabot[bot] avatar honjes avatar thematlin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.