UNPKG

18.9 kBMarkdownView Raw
1node-csgo
2========
3
4Need help? Don't open an issue - ask in the Gitter room.
5
6[![Join the chat at https://gitter.im/joshuaferrara/node-csgo](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/joshuaferrara/node-csgo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
8[![Build Status](https://travis-ci.org/joshuaferrara/node-csgo.svg?branch=master)](https://travis-ci.org/joshuaferrara/node-csgo)
9[![Code Climate](https://codeclimate.com/github/joshuaferrara/node-csgo/badges/gpa.svg)](https://codeclimate.com/github/joshuaferrara/node-csgo)
10
11[![NPM](https://nodei.co/npm/csgo.png?downloads=true&stars=true)](https://nodei.co/npm/csgo/)
12
13---
14
15A node-steam plugin for Counter-Strike: Global Offensive.
16
17Based on [node-dota2](https://github.com/RJacksonm1/node-dota2) by [RJacksonm1](https://github.com/RJacksonm1/)
18
19# Used by
20* [PopFlash](https://popflash.site/) - Alternative CS:GO matchmaking & PUG service.
21* [steamgaug.es](https://steamgaug.es/) - Matchmaking status info for CS:GO, TF2 & Dota 2. Also includes general steam status.
22* [Claimony](http://www.claimony.com/) - Get rewarded for gaming
23* [CSGOSquad](http://csgosquad.com) - Live MM game search and statistics
24* [CS:GO Stats](https://csgostats.gg/) - Detailed insights and statistics for competitive CS:GO
25* [CS:GORecords](https://csgorecords.com/) - Track the history of your CS:GO stats!
26* [CSGO-Mates](http://www.csgo-mates.com/) - Live matchmaking search and player insights
27
28> This list is getting too long. Wanna be on it? Message me on Gitter and we'll talk. - joshuaferrara
29
30# Requirements
31* node-steam
32* CS:GO must be purchased on the account you sign in with.
33
34# Initializing
35Parameters:
36* `steamUser` - Pass a SteamUser instance to change your current status(In-game/not).
37* `steamGC` - Pass a SteamGameCoordinator instance to use to send & receive GC messages.
38* `debug` - A boolean noting whether to print information about operations to console.
39
40```js
41var Steam = require('steam'),
42 steamClient = new Steam.SteamClient(),
43 steamUser = new Steam.SteamUser(steamClient),
44 steamGC = new Steam.SteamGameCoordinator(steamClient, 730),
45 csgo = require('csgo'),
46 CSGO = new csgo.CSGOClient(steamUser, steamGC, false);
47```
48
49# Methods
50All methods require the SteamClient instance to be logged on.
51
52## CSGO
53
54### `launch()`
55
56Reports to Steam that you're playing Counter-Strike: Global Offensive, and then initiates communication with the Game Coordinator.
57
58### `exit()`
59
60Tells Steam that you are not playing CS:GO.
61
62### `ToAccountID(steamId)`
63
64Converts a 64 bit steam ID to an account ID.
65
66### `ToSteamID(accountId)`
67
68Converts an account ID to a 64 bit steam ID.
69
70### `Rank.getString(int rank_id)`
71
72Converts an integer rank_id to a string. Ex: `CSGO.Rank.getString(1) = "Silver I"`
73
74### `Level.getString(int player_level)`
75
76Converts an integer player_level to a string. Ex: `CSGO.Level.getString(1) = "Recruit"`
77
78## Matches
79
80### `matchmakingStatsRequest()`
81
82Sends a message to the Game Coordinator requesting some matchmaking stats. Listen for the `matchmakingStatsData` event for the game coordinator's response. Requires the GC to be ready (listen for the `ready` event before calling).
83
84### `requestRecentGames()`
85
86Requests a list of recent games for the currently logged in account. Listen for the `matchList` event for the game coordinator's response.
87
88### `requestLiveGameForUser(accountId)`
89
90Requests current live game info for given user. Listen for the `matchList` event for the game coordinator's response.
91
92### `requestGame(string matchid, string outcomeid, int token)`
93
94Requests info about game given a matchId, outcomeId, and token for a game (Tip: These can be found with the Sharecode decoder). Listen for the `matchList` event for the game coordinator's response.
95
96### `requestWatchInfoFriends(arguments)`
97
98Requests watchable info for game.
99Arguments:
100```javascript
101int request_id; //Not enough tests yet
102account_ids[array_of_csgo_accounts];//Not enough tests yet
103long serverid;//ServerID of match.
104long matchid;//MatchID of match.
105```
106Example:
107```javascript
108CSGO.requestWatchInfoFriends({
109 serverid: new Long(-569600767, -2130640678, true).toString(),
110 matchid: new Long(39, 719230023, true).toString()
111});
112```
113Requirements: game should be live.
114
115Listen for the `watchList` event for the game coordinator's response.
116
117### `requestCurrentLiveGames()`
118
119Requests a list of current live games. Listen for the `matchList` event for the game coordinator's response.
120
121## Player Info
122
123### `playerProfileRequest(accountId)`
124
125`accountId` is the player's account ID (A player's SteamID64 can be converted to an account ID with `CSGO.ToAccountID(steamid)`).
126
127Requests a player's profile from the game coordinator. The player must be online and playing CS:GO. Listen for the `playerProfile` event for the game coordinator's response.
128
129## Rich Presence
130
131### `richPresenceUpload(richPresenceObject)`
132
133Sets the rich presence object for the currently logged in user. Rich presence is Valve's solution to giving friends information on what you're doing in a game. For example, when you see information about another friends matchmaking game (as in, the map and score), this is set by using rich presence. An example of how to use this method can be found in [example.js](https://github.com/joshuaferrara/node-csgo/blob/master/example/example.js)
134
135## Item Data
136
137### `itemDataRequest(string s, string a, string d, string m)`
138
139Requests item data for the specified CSGO item inspect link parameters. The parameter `s` has a value when the inspect link is from an inventory; likewise, the parameter `m` has a value when the inspect link is from the market. If there is no value for a given parameter from the inspect link, set it to `"0"`.
140
141Listen for the `itemData` event for the game coordinator's response.
142
143Example for an inventory inspect link for a CSGO item
144```javascript
145// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198084749846A6768147729D12557175561287951743
146CSGO.itemDataRequest("76561198084749846", "6768147729", "12557175561287951743", "0");
147```
148
149Example for a market inspect link for a CSGO item
150```javascript
151// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M563330426657599553A6710760926D9406593057029549017
152CSGO.itemDataRequest("0", "6710760926", "9406593057029549017", "563330426657599553");
153```
154
155
156## Sharecode Decoding/Encoding
157
158### `new CSGO.SharecodeDecoder(string code);`
159
160Instantiates a SharecodeDecoder class to decode sharecodes.
161
162Calling the `decode()` method of the `SharecodeDecoder` will return an object with the decoded information.
163
164```javascript
165console.log(new CSGO.SharecodeDecoder("CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD").decode())
166
167{ matchId: '3106049990460440633',
168 outcomeId: '3106056003414655216',
169 tokenId: '11842' }
170```
171
172# Events
173### `ready`
174Emitted when the GC is ready to receive messages. Be careful not to declare anonymous functions as event handlers here, as you'll need to be able to invalidate event handlers on an `unready` event.
175
176### `unready`
177Emitted when the connection status to the GC changes, and renders the library unavailable to interact. You should clear any event handlers set in the `ready` event here, otherwise you'll have multiple handlers for each message every time a new `ready` event is sent.
178
179### `exited`
180Emitted when `.exit()` is called as a convenience for clearing handlers upon intentional exits.
181
182### `itemData` (`itemDataResponse`)
183
184```javascript
185{
186 "iteminfo":
187 {
188 "accountid": null,
189 "itemid": Long { "low": -1821786863, "high": 1, "unsigned": true },
190 "defindex": 7,
191 "paintindex": 474,
192 "rarity": 6,
193 "quality": 4,
194 "paintwear": 1054492909,
195 "paintseed": 183,
196 "killeaterscoretype": null,
197 "killeatervalue": null,
198 "customname": null,
199 "stickers": [],
200 "inventory": 3221225475,
201 "origin": 8,
202 "questid": null,
203 "dropreason": null,
204 "floatvalue": 0.4263376295566559
205 }
206}
207```
208
209Emitted when the game coordinator responds to the `itemDataRequest` method.
210
211### `matchmakingStatsData` (`matchmakingStatsResponse`)
212* `matchmakingStatsResponse` - Raw response object. Example response below.
213
214```json
215{
216 "account_id": 137013074,
217 "ongoingmatch": null,
218 "global_stats": {
219 "players_online": 423480,
220 "servers_online": 132472,
221 "players_searching": 4212,
222 "servers_available": 65497,
223 "ongoing_matches": 17016,
224 "search_time_avg": 46530,
225 "search_statistics": [
226 {
227 "game_type": 264,
228 "search_time_avg": 128555,
229 "players_searching": 148
230 },
231 {
232 "game_type": 520,
233 "search_time_avg": 31962,
234 "players_searching": 1768
235 },
236 {
237 "game_type": 1032,
238 "search_time_avg": 122353,
239 "players_searching": 426
240 },
241 {
242 "game_type": 2056,
243 "search_time_avg": 136133,
244 "players_searching": 160
245 },
246 {
247 "game_type": 4104,
248 "search_time_avg": 62643,
249 "players_searching": 1069
250 },
251 {
252 "game_type": 8200,
253 "search_time_avg": 70380,
254 "players_searching": 563
255 },
256 {
257 "game_type": 16392,
258 "search_time_avg": 115923,
259 "players_searching": 132
260 },
261 {
262 "game_type": 32776,
263 "search_time_avg": 54906,
264 "players_searching": 1248
265 },
266 {
267 "game_type": 65544,
268 "search_time_avg": 116871,
269 "players_searching": 183
270 },
271 {
272 "game_type": 131080,
273 "search_time_avg": 82308,
274 "players_searching": 145
275 },
276 {
277 "game_type": 262152,
278 "search_time_avg": 209331,
279 "players_searching": 105
280 },
281 {
282 "game_type": 524296,
283 "search_time_avg": 270376,
284 "players_searching": 110
285 },
286 {
287 "game_type": 1048584,
288 "search_time_avg": 64499,
289 "players_searching": 1020
290 },
291 {
292 "game_type": 268435464,
293 "search_time_avg": 84615,
294 "players_searching": 642
295 },
296 {
297 "game_type": 536870920,
298 "search_time_avg": 104965,
299 "players_searching": 478
300 },
301 {
302 "game_type": 2097160,
303 "search_time_avg": 198734,
304 "players_searching": 228
305 },
306 {
307 "game_type": 134217736,
308 "search_time_avg": 147703,
309 "players_searching": 203
310 },
311 {
312 "game_type": 8388616,
313 "search_time_avg": 538828,
314 "players_searching": 138
315 },
316 {
317 "game_type": 16777224,
318 "search_time_avg": 232350,
319 "players_searching": 192
320 },
321 {
322 "game_type": 4194312,
323 "search_time_avg": 237269,
324 "players_searching": 151
325 },
326 {
327 "game_type": 33554440,
328 "search_time_avg": 203183,
329 "players_searching": 181
330 }
331 ],
332 "main_post_url": "",
333 "required_appid_version": 13494,
334 "pricesheet_version": 1438240620,
335 "twitch_streams_version": 2,
336 "active_tournament_eventid": 6,
337 "active_survey_id": 0
338 },
339 "penalty_seconds": null,
340 "penalty_reason": null,
341 "vac_banned": 0,
342 "ranking": {
343 "account_id": 137013074,
344 "rank_id": 11,
345 "wins": 192,
346 "rank_change": null
347 },
348 "commendation": {
349 "cmd_friendly": 3,
350 "cmd_teaching": 3,
351 "cmd_leader": 3
352 },
353 "medals": {
354 "medal_team": 0,
355 "medal_combat": 0,
356 "medal_weapon": 0,
357 "medal_global": 0,
358 "medal_arms": 0,
359 "display_items_defidx": [],
360 "featured_display_item_defidx": null
361 },
362 "my_current_event": null,
363 "my_current_event_teams": [],
364 "my_current_team": null,
365 "my_current_event_stages": [],
366 "survey_vote": null,
367 "activity": null,
368 "player_level": 3,
369 "player_cur_xp": 327684342,
370 "player_xp_bonus_flags": null
371}
372```
373
374Emitted when the game coordinator responds to the `matchmakingStatsRequest` method.
375
376### `playerProfile` (Response to `playerProfileRequest`)
377
378
379```json
380{
381 "request_id": null,
382 "account_profiles": [
383 {
384 "account_id": 137013074,
385 "ongoingmatch": null,
386 "global_stats": null,
387 "penalty_seconds": null,
388 "penalty_reason": null,
389 "vac_banned": null,
390 "ranking": {
391 "account_id": 137013074,
392 "rank_id": 11,
393 "wins": 192,
394 "rank_change": null
395 },
396 "commendation": {
397 "cmd_friendly": 3,
398 "cmd_teaching": 3,
399 "cmd_leader": 3
400 },
401 "medals": {
402 "medal_team": 0,
403 "medal_combat": 0,
404 "medal_weapon": 0,
405 "medal_global": 0,
406 "medal_arms": 0,
407 "display_items_defidx": [],
408 "featured_display_item_defidx": null
409 },
410 "my_current_event": null,
411 "my_current_event_teams": [],
412 "my_current_team": null,
413 "my_current_event_stages": [],
414 "survey_vote": null,
415 "activity": null,
416 "player_level": 3,
417 "player_cur_xp": 327684342,
418 "player_xp_bonus_flags": null
419 }
420 ]
421}
422```
423
424Emitted when the game coordinator responds to the `playerProfileRequest` method.
425
426## `matchList` (Response to `requestRecentGames`)
427
428The whole response ended up being too big for the readme and caused browsers to crash. Due to this, I've only included an excerpt as to what's returned.
429
430```json
431 {
432 "reservationid": {
433 "low": 65,
434 "high": 715485165,
435 "unsigned": true
436 },
437 "reservation": {
438 "account_ids": [
439 2879081,
440 182261908,
441 225695551,
442 30039512,
443 90132590,
444 94815387,
445 37671978,
446 31906737,
447 137013074,
448 61347894
449 ],
450 "game_type": 1032,
451 "match_id": null,
452 "server_version": null,
453 "rankings": [],
454 "encryption_key": null,
455 "encryption_key_pub": null,
456 "party_ids": [],
457 "whitelist": [],
458 "tv_master_steamid": null,
459 "tournament_event": null,
460 "tournament_teams": [],
461 "tournament_casters_account_ids": [],
462 "tv_relay_steamid": null,
463 "pre_match_data": null
464 },
465 "map": "http://replay124.valve.net/730/003072985384448163905_0699089210.dem.bz2",
466 "round": null,
467 "kills": [
468 21,
469 22,
470 15,
471 15,
472 12,
473 37,
474 20,
475 23,
476 17,
477 15
478 ],
479 "assists": [
480 5,
481 5,
482 1,
483 3,
484 4,
485 2,
486 3,
487 2,
488 6,
489 7
490 ],
491 "deaths": [
492 22,
493 22,
494 24,
495 23,
496 21,
497 13,
498 13,
499 19,
500 20,
501 20
502 ],
503 "scores": [
504 55,
505 54,
506 40,
507 39,
508 37,
509 79,
510 65,
511 59,
512 41,
513 37
514 ],
515 "pings": [],
516 "round_result": null,
517 "match_result": 2,
518 "team_scores": [
519 11,
520 16
521 ],
522 "confirm": null,
523 "reservation_stage": null,
524 "match_duration": 2332,
525 "enemy_kills": [
526 21,
527 22,
528 15,
529 15,
530 12,
531 37,
532 20,
533 23,
534 17,
535 15
536 ],
537 "enemy_headshots": [
538 12,
539 11,
540 4,
541 2,
542 3,
543 9,
544 6,
545 9,
546 3,
547 12
548 ],
549 "enemy_3ks": [],
550 "enemy_4ks": [],
551 "enemy_5ks": [],
552 "mvps": [
553 4,
554 3,
555 1,
556 1,
557 2,
558 4,
559 5,
560 2,
561 3,
562 2
563 ],
564 "spectators_count": null,
565 "spectators_count_tv": null,
566 "spectators_count_lnk": null,
567 "enemy_kills_agg": []
568 }
569```
570
571Emitted when `requestRecentGames`, `requestGame`, `requestLiveGameForUser`, `requestCurrentLiveGames` is replied to.
572
573## `watchList` (Response to `requestWatchInfoFriends`)
574Example:
575```json
576{
577 "request_id": 0,
578 "account_ids": [],
579 "watchable_match_infos": [
580 {
581 "server_ip": 2453839835,
582 "tv_port": 28056,
583 "tv_spectators": 1,
584 "tv_time": 417,
585 "tv_watch_password": {
586 "buffer": {
587 "type": "Buffer",
588 "data": [ ]
589 },
590 "offset": 21,
591 "markedOffset": -1,
592 "limit": 53,
593 "littleEndian": true,
594 "noAssert": false
595 },
596 "cl_decryptdata_key": null,
597 "cl_decryptdata_key_pub": {
598 "low": -249571153,
599 "high": 1941167002,
600 "unsigned": true
601 },
602 "game_type": 32776,
603 "game_mapgroup": "mg_de_mirage",
604 "game_map": "de_mirage",
605 "server_id": {
606 "low": 2054631424,
607 "high": 20977258,
608 "unsigned": true
609 },
610 "match_id": {
611 "low": 32,
612 "high": 719254593,
613 "unsigned": true
614 },
615 "reservation_id": null
616 }
617 ],
618 "extended_timeout": null
619}
620```