Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cs2-api: Counter-Strike 2 API client for JavaScript and Python

npm PyPI license

This is the official client for the CS2 API at cs2-api.org. It covers:

  • live Counter-Strike 2 match scores and round-level scoreboards
  • match results, schedules and streams
  • player stats (rating, ADR, KAST, K/D) and leaderboards
  • teams, rosters and head-to-head
  • the world ranking and Valve Regional Standings (VRS)
  • events, standings and brackets
  • transfers
  • CS2 skin prices across 25+ marketplaces, with price history

It has zero dependencies. The JavaScript client ships TypeScript types and works as ESM or CommonJS; the Python client needs only the standard library.

You need a free API key (500 requests/month, no card): Get your key

Install

npm install cs2-api
pip install cs2-api-client

JavaScript / TypeScript

import { CS2Api } from "cs2-api";            // or: const { CS2Api } = require("cs2-api")

const cs2 = new CS2Api();                     // reads process.env.CITO_API_KEY

const live = await cs2.live();                // every match being played right now
for (const m of live) {
  console.log(`${m.team1Name} ${m.team1Score}-${m.team2Score} ${m.team2Name} · ${m.currentMap}`);
}

const ranking = await cs2.worldRanking({ limit: 10 });
const vitality = await cs2.team("vitality");  // roster + recent results
const donk = await cs2.player("donk");
const prices = await cs2.skinPrices("ak-47-redline-field-tested-1ab1a2dc");

Python

from cs2_api import CS2Api

cs2 = CS2Api()  # reads CITO_API_KEY

for m in cs2.live():
    print(f"{m['team1Name']} {m['team1Score']}-{m['team2Score']} {m['team2Name']} · {m['currentMap']}")

ranking = cs2.world_ranking(limit=10)
vitality = cs2.team("vitality")
donk = cs2.player("donk")
prices = cs2.skin_prices("ak-47-redline-field-tested-1ab1a2dc")

Methods

JavaScript uses camelCase and Python uses snake_case (worldRanking / world_ranking). Teams, players and events accept an id or a slug (vitality, donk).

Area Methods
Live live(), liveScoreboard(matchId): sides, round, player K/D/ADR
Matches upcoming(), results(), today(), match(id), matchMaps(id), matchPlayerStats(id), matchStreams(id)
Teams team(slug), teamMatches(slug), teamStats(slug), teamMapStats(slug), headToHead(a, b)
Players player(slug), searchPlayers(q), playerStats(slug), playerMatches(slug)
Events events({ status }), event(slug), eventMatches(slug), eventStandings(slug), eventBracket(slug)
Rankings & stats worldRanking(), vrsRanking(), leaderboard(metric), transfers(), search(q)
Skins searchSkins(q), skin(slug), skinPrices(slug), skinHistory(slug), trendingSkins()
Anything else get(path, query, { raw }): any of the 140+ endpoints, with meta for pagination when raw: true

Errors throw CS2ApiError (JS) or raise CS2ApiError (Python), with status and the API's message.

Use cases

Keep your key safe

Keep it in an environment variable or .env (git-ignored). Call the API from your server, never from browser code. If a key leaks, revoke it in your dashboard and create a new one.

Links

Not affiliated with Valve, HLTV, ESL, BLAST or PGL. MIT licensed.

About

CS2 API client for JavaScript and Python: Counter-Strike 2 live scores, results, player stats, teams, rankings, events and skin prices. npm install cs2-api / pip install cs2-api

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages