Welcome to csgo’s documentation!

Latest version released on PyPi MIT License

Supports Python 2.7+ and 3.4+.

Module based on steam for interacting with CSGO’s Game Coordinator.

As always contributions and suggestions are welcome. Just visit the repository on github.

User Guide

User Guide

This part of the documentation is a quick start for writing applications that interact with the game coordinator for CSGO.

Initialization

This is the minimal code we need to get a session with the game coordnator.

from steam.client import SteamClient
from csgo.client import CSGOClient

client = SteamClient()
cs = CSGOClient(client)

@client.on('logged_on')
def start_csgo():
    cs.launch()

@cs.on('ready')
def gc_ready():
    # send messages to gc
    pass

client.cli_login()
client.run_forever()
You won’t see any output running the code above.
In order to peek inside we need to setup debug logging.

See the Configure console logging section

Sending/Recieving messages

Let’s request profile of the currently logged on user. We only need the account id. If need to convert from steam id or any other format see SteamID.

from csgo.enums import ECsgoGCMsg

# send request message
self.send(ECsgoGCMsg.EMsgGCCStrike15_v2_ClientRequestPlayersProfile, {
            'account_id': cs.account_id,
            'request_level': 32,
         })

# listen for the response
response, = cs.wait_event(ECsgoGCMsg.EMsgGCCStrike15_v2_PlayersProfile, timeout=10)
player_profle = response.account_profiles[0]

Alternatively, we can do the same using one of the methods from features, which implements that particular request for us. Specifically csgo.features.player.Player.request_player_profile

cs.request_player_profile(cs.account_id)
response, = cs.wait_event('player_profile')
>>> str(response)
account_id: 12345678
ranking {
  account_id: 12345678
  rank_id: 0
  wins: 123
}
commendation {
  cmd_friendly: 1
  cmd_teaching: 2
  cmd_leader: 3
}
medals {
  medal_team: 0
  medal_combat: 0
  medal_weapon: 0
  medal_global: 0
  medal_arms: 0
}
player_level: 1
player_cur_xp: 262840000

Working with events

The module makes use of gevent and gevent-eventemitter. Events work similiarly to EventEmitter in javascript. Nevertheless, here is quick rundown.

To catch an event we need to register a callback

@cs.on('my event')
def do_stuff(a, b):
    print "Hey!"

cs.on('my event', do_stuff)
cs.once('my event', do_stuff)  # call do_stuff just one time
cs.wait_event('my event')      # blocks and returns arguments, if any

Note

wait_event may block forever, so use the timeout parameter

Emitting an event is just as simple.

cs.emit("my event")
cs.emit("my event", 1, [3,4,5])  # optional arguments

That’s it. For more details see gevent-eventemitter.

Configure console logging

Here is a basic configuration to get debug messages in the console.

import logging

logging.basicConfig(format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG)

The we run the program and the console ouput should look something like this:

[2016-01-01 12:34:56,000] DEBUG CMClient: Connect initiated.
[2016-01-01 12:34:56,000] DEBUG Connection: Attempting connection to ('208.78.164.13', 27018)
[2016-01-01 12:34:56,000] DEBUG Connection: Connected.
[2016-01-01 12:34:56,000] DEBUG CMClient: Emit event: 'connected'
[2016-01-01 12:34:56,000] DEBUG SteamClient: Emit event: 'connected'
[2016-01-01 12:34:56,000] DEBUG SteamClient: Attempting login
[2016-01-01 12:34:56,000] DEBUG CMClient: Incoming: <Msg <EMsg.ChannelEncryptRequest: 1303>>
[2016-01-01 12:34:56,000] DEBUG CMClient: Emit event: <EMsg.ChannelEncryptRequest: 1303>
...

API Documentation

csgo API

Documentation related to various APIs available in this package.

msg

Various utility function for dealing with messages.

csgo.msg.get_emsg_enum(emsg)

Attempts to find the Enum for the given int

Parameters:emsg (int) – integer corresponding to a Enum
Returns:Enum if found, emsg if not
Return type:Enum, int
csgo.msg.find_proto(emsg)

Attempts to find the protobuf message for a given Enum

Parameters:emsg (Enum) – Enum corrensponding to a protobuf message
Returns:protobuf message class

enums

class csgo.common_enums.ESOType
CSOEconItem = 1
CSOPersonaDataPublic = 2
CSOItemRecipe = 5
CSOEconGameAccountClient = 7
CSOEconItemDropRateBonus = 38
CSOEconItemEventTicket = 40
CSOAccountSeasonalOperation = 41
CSOEconDefaultEquippedDefinitionInstanceClient = 43
CSOEconCoupon = 45
CSOQuestProgress = 46
class csgo.common_enums.EXPBonusFlag
EarnedXpThisPeriod = 1
FirstReward = 2
Msg_YourReportGotConvicted = 4
Msg_YouPartiedWithCheaters = 8
PrestigeEarned = 16
ChinaGovernmentCert = 32
OverwatchBonus = 268435456
BonusBoostConsumed = 536870912
ReducedGain = 1073741824
class csgo.proto_enums.EClientReportingVersion
OldVersion = 0
BetaVersion = 1
SupportsTrustedMode = 2
class csgo.proto_enums.ECommunityItemAttribute
Invalid = 0
CardBorder = 1
Level = 2
IssueNumber = 3
TradableTime = 4
StorePackageID = 5
CommunityItemAppID = 6
CommunityItemType = 7
ProfileModiferEnabled = 8
ExpiryTime = 9
class csgo.proto_enums.ECommunityItemClass
Invalid = 0
Badge = 1
GameCard = 2
ProfileBackground = 3
Emoticon = 4
BoosterPack = 5
Consumable = 6
GameGoo = 7
ProfileModifier = 8
Scene = 9
SalienItem = 10
class csgo.proto_enums.ECsgoGCMsg
EMsgGCCStrike15_v2_Base = 9100
EMsgGCCStrike15_v2_MatchmakingStart = 9101
EMsgGCCStrike15_v2_MatchmakingStop = 9102
EMsgGCCStrike15_v2_MatchmakingClient2ServerPing = 9103
EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate = 9104
EMsgGCCStrike15_v2_MatchmakingServerReservationResponse = 9106
EMsgGCCStrike15_v2_MatchmakingGC2ClientReserve = 9107
EMsgGCCStrike15_v2_MatchmakingClient2GCHello = 9109
EMsgGCCStrike15_v2_MatchmakingGC2ClientHello = 9110
EMsgGCCStrike15_v2_MatchmakingGC2ClientAbandon = 9112
EMsgGCCStrike15_v2_MatchmakingGCOperationalStats = 9115
EMsgGCCStrike15_v2_MatchmakingOperator2GCBlogUpdate = 9117
EMsgGCCStrike15_v2_ServerNotificationForUserPenalty = 9118
EMsgGCCStrike15_v2_ClientReportPlayer = 9119
EMsgGCCStrike15_v2_ClientReportServer = 9120
EMsgGCCStrike15_v2_ClientCommendPlayer = 9121
EMsgGCCStrike15_v2_ClientReportResponse = 9122
EMsgGCCStrike15_v2_ClientCommendPlayerQuery = 9123
EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse = 9124
EMsgGCCStrike15_v2_WatchInfoUsers = 9126
EMsgGCCStrike15_v2_ClientRequestPlayersProfile = 9127
EMsgGCCStrike15_v2_PlayersProfile = 9128
EMsgGCCStrike15_v2_PlayerOverwatchCaseUpdate = 9131
EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment = 9132
EMsgGCCStrike15_v2_PlayerOverwatchCaseStatus = 9133
EMsgGCCStrike15_v2_GC2ClientTextMsg = 9134
EMsgGCCStrike15_v2_Client2GCTextMsg = 9135
EMsgGCCStrike15_v2_MatchEndRunRewardDrops = 9136
EMsgGCCStrike15_v2_MatchEndRewardDropsNotification = 9137
EMsgGCCStrike15_v2_ClientRequestWatchInfoFriends2 = 9138
EMsgGCCStrike15_v2_MatchList = 9139
EMsgGCCStrike15_v2_MatchListRequestCurrentLiveGames = 9140
EMsgGCCStrike15_v2_MatchListRequestRecentUserGames = 9141
EMsgGCCStrike15_v2_GC2ServerReservationUpdate = 9142
EMsgGCCStrike15_v2_ClientVarValueNotificationInfo = 9144
EMsgGCCStrike15_v2_MatchListRequestTournamentGames = 9146
EMsgGCCStrike15_v2_MatchListRequestFullGameInfo = 9147
EMsgGCCStrike15_v2_GiftsLeaderboardRequest = 9148
EMsgGCCStrike15_v2_GiftsLeaderboardResponse = 9149
EMsgGCCStrike15_v2_ServerVarValueNotificationInfo = 9150
EMsgGCCStrike15_v2_ClientSubmitSurveyVote = 9152
EMsgGCCStrike15_v2_Server2GCClientValidate = 9153
EMsgGCCStrike15_v2_MatchListRequestLiveGameForUser = 9154
EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest = 9156
EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse = 9157
EMsgGCCStrike15_v2_AccountPrivacySettings = 9158
EMsgGCCStrike15_v2_SetMyActivityInfo = 9159
EMsgGCCStrike15_v2_MatchListRequestTournamentPredictions = 9160
EMsgGCCStrike15_v2_MatchListUploadTournamentPredictions = 9161
EMsgGCCStrike15_v2_DraftSummary = 9162
EMsgGCCStrike15_v2_ClientRequestJoinFriendData = 9163
EMsgGCCStrike15_v2_ClientRequestJoinServerData = 9164
EMsgGCCStrike15_v2_ClientRequestNewMission = 9165
EMsgGCCStrike15_v2_GC2ClientTournamentInfo = 9167
EMsgGC_GlobalGame_Subscribe = 9168
EMsgGC_GlobalGame_Unsubscribe = 9169
EMsgGC_GlobalGame_Play = 9170
EMsgGCCStrike15_v2_AcknowledgePenalty = 9171
EMsgGCCStrike15_v2_Client2GCRequestPrestigeCoin = 9172
EMsgGCCStrike15_v2_GC2ClientGlobalStats = 9173
EMsgGCCStrike15_v2_Client2GCStreamUnlock = 9174
EMsgGCCStrike15_v2_FantasyRequestClientData = 9175
EMsgGCCStrike15_v2_FantasyUpdateClientData = 9176
EMsgGCCStrike15_v2_GCToClientSteamdatagramTicket = 9177
EMsgGCCStrike15_v2_ClientToGCRequestTicket = 9178
EMsgGCCStrike15_v2_ClientToGCRequestElevate = 9179
EMsgGCCStrike15_v2_GlobalChat = 9180
EMsgGCCStrike15_v2_GlobalChat_Subscribe = 9181
EMsgGCCStrike15_v2_GlobalChat_Unsubscribe = 9182
EMsgGCCStrike15_v2_ClientAuthKeyCode = 9183
EMsgGCCStrike15_v2_GotvSyncPacket = 9184
EMsgGCCStrike15_v2_ClientPlayerDecalSign = 9185
EMsgGCCStrike15_v2_ClientLogonFatalError = 9187
EMsgGCCStrike15_v2_ClientPollState = 9188
EMsgGCCStrike15_v2_Party_Register = 9189
EMsgGCCStrike15_v2_Party_Unregister = 9190
EMsgGCCStrike15_v2_Party_Invite = 9192
EMsgGCCStrike15_v2_Account_RequestCoPlays = 9193
EMsgGCCStrike15_v2_ClientGCRankUpdate = 9194
EMsgGCCStrike15_v2_ClientRequestOffers = 9195
EMsgGCCStrike15_v2_ClientAccountBalance = 9196
EMsgGCCStrike15_v2_ClientPartyJoinRelay = 9197
EMsgGCCStrike15_v2_ClientPartyWarning = 9198
EMsgGCCStrike15_v2_SetEventFavorite = 9200
EMsgGCCStrike15_v2_GetEventFavorites_Request = 9201
EMsgGCCStrike15_v2_ClientPerfReport = 9202
EMsgGCCStrike15_v2_GetEventFavorites_Response = 9203
EMsgGCCStrike15_v2_ClientRequestSouvenir = 9204
EMsgGCCStrike15_v2_ClientReportValidation = 9205
EMsgGCCStrike15_v2_GC2ClientRefuseSecureMode = 9206
EMsgGCCStrike15_v2_GC2ClientRequestValidation = 9207
EMsgGCCStrike15_v2_ClientRedeemMissionReward = 9209
EMsgGCCStrike15_ClientDeepStats = 9210
EMsgGCCStrike15_StartAgreementSessionInGame = 9211
class csgo.proto_enums.ECsgoSteamUserStat
XpEarnedGames = 1
MatchWinsCompetitive = 2
SurvivedDangerZone = 3
class csgo.proto_enums.EGCBaseClientMsg
EMsgGCClientWelcome = 4004
EMsgGCServerWelcome = 4005
EMsgGCClientHello = 4006
EMsgGCServerHello = 4007
EMsgGCClientConnectionStatus = 4009
EMsgGCServerConnectionStatus = 4010
EMsgGCClientHelloPartner = 4011
EMsgGCClientHelloPW = 4012
EMsgGCClientHelloR2 = 4013
EMsgGCClientHelloR3 = 4014
EMsgGCClientHelloR4 = 4015
class csgo.proto_enums.EGCItemCustomizationNotification
NameItem = 1006
UnlockCrate = 1007
XRayItemReveal = 1008
XRayItemClaim = 1009
CasketTooFull = 1011
CasketContents = 1012
CasketAdded = 1013
CasketRemoved = 1014
CasketInvFull = 1015
NameBaseItem = 1019
RemoveItemName = 1030
RemoveSticker = 1053
ApplySticker = 1086
StatTrakSwap = 1088
RemovePatch = 1089
ApplyPatch = 1090
ActivateFanToken = 9178
ActivateOperationCoin = 9179
GraffitiUnseal = 9185
GenerateSouvenir = 9204
ClientRedeemMissionReward = 9209
class csgo.proto_enums.EGCItemMsg
EMsgGCBase = 1000
EMsgGCSetItemPosition = 1001
EMsgGCCraft = 1002
EMsgGCCraftResponse = 1003
EMsgGCDelete = 1004
EMsgGCVerifyCacheSubscription = 1005
EMsgGCNameItem = 1006
EMsgGCUnlockCrate = 1007
EMsgGCUnlockCrateResponse = 1008
EMsgGCPaintItem = 1009
EMsgGCPaintItemResponse = 1010
EMsgGCGoldenWrenchBroadcast = 1011
EMsgGCMOTDRequest = 1012
EMsgGCMOTDRequestResponse = 1013
EMsgGCAddItemToSocket_DEPRECATED = 1014
EMsgGCAddItemToSocketResponse_DEPRECATED = 1015
EMsgGCAddSocketToBaseItem_DEPRECATED = 1016
EMsgGCAddSocketToItem_DEPRECATED = 1017
EMsgGCAddSocketToItemResponse_DEPRECATED = 1018
EMsgGCNameBaseItem = 1019
EMsgGCNameBaseItemResponse = 1020
EMsgGCRemoveSocketItem_DEPRECATED = 1021
EMsgGCRemoveSocketItemResponse_DEPRECATED = 1022
EMsgGCCustomizeItemTexture = 1023
EMsgGCCustomizeItemTextureResponse = 1024
EMsgGCUseItemRequest = 1025
EMsgGCUseItemResponse = 1026
EMsgGCGiftedItems_DEPRECATED = 1027
EMsgGCRemoveItemName = 1030
EMsgGCRemoveItemPaint = 1031
EMsgGCGiftWrapItem = 1032
EMsgGCGiftWrapItemResponse = 1033
EMsgGCDeliverGift = 1034
EMsgGCDeliverGiftResponseGiver = 1035
EMsgGCDeliverGiftResponseReceiver = 1036
EMsgGCUnwrapGiftRequest = 1037
EMsgGCUnwrapGiftResponse = 1038
EMsgGCSetItemStyle = 1039
EMsgGCUsedClaimCodeItem = 1040
EMsgGCSortItems = 1041
EMsgGC_RevolvingLootList_DEPRECATED = 1042
EMsgGCLookupAccount = 1043
EMsgGCLookupAccountResponse = 1044
EMsgGCLookupAccountName = 1045
EMsgGCLookupAccountNameResponse = 1046
EMsgGCUpdateItemSchema = 1049
EMsgGCRemoveCustomTexture = 1051
EMsgGCRemoveCustomTextureResponse = 1052
EMsgGCRemoveMakersMark = 1053
EMsgGCRemoveMakersMarkResponse = 1054
EMsgGCRemoveUniqueCraftIndex = 1055
EMsgGCRemoveUniqueCraftIndexResponse = 1056
EMsgGCSaxxyBroadcast = 1057
EMsgGCBackpackSortFinished = 1058
EMsgGCAdjustItemEquippedState = 1059
EMsgGCCollectItem = 1061
EMsgGCItemAcknowledged__DEPRECATED = 1062
EMsgGC_ReportAbuse = 1065
EMsgGC_ReportAbuseResponse = 1066
EMsgGCNameItemNotification = 1068
EMsgGCApplyConsumableEffects = 1069
EMsgGCConsumableExhausted = 1070
EMsgGCShowItemsPickedUp = 1071
EMsgGCClientDisplayNotification = 1072
EMsgGCApplyStrangePart = 1073
EMsgGC_IncrementKillCountAttribute = 1074
EMsgGC_IncrementKillCountResponse = 1075
EMsgGCApplyPennantUpgrade = 1076
EMsgGCSetItemPositions = 1077
EMsgGCApplyEggEssence = 1078
EMsgGCNameEggEssenceResponse = 1079
EMsgGCPaintKitItem = 1080
EMsgGCPaintKitBaseItem = 1081
EMsgGCPaintKitItemResponse = 1082
EMsgGCGiftedItems = 1083
EMsgGCUnlockItemStyle = 1084
EMsgGCUnlockItemStyleResponse = 1085
EMsgGCApplySticker = 1086
EMsgGCItemAcknowledged = 1087
EMsgGCStatTrakSwap = 1088
EMsgGCUserTrackTimePlayedConsecutively = 1089
EMsgGCItemCustomizationNotification = 1090
EMsgGCModifyItemAttribute = 1091
EMsgGCCasketItemAdd = 1092
EMsgGCCasketItemExtract = 1093
EMsgGCCasketItemLoadContents = 1094
EMsgGCTradingBase = 1500
EMsgGCTrading_InitiateTradeRequest = 1501
EMsgGCTrading_InitiateTradeResponse = 1502
EMsgGCTrading_StartSession = 1503
EMsgGCTrading_SetItem = 1504
EMsgGCTrading_RemoveItem = 1505
EMsgGCTrading_UpdateTradeInfo = 1506
EMsgGCTrading_SetReadiness = 1507
EMsgGCTrading_ReadinessResponse = 1508
EMsgGCTrading_SessionClosed = 1509
EMsgGCTrading_CancelSession = 1510
EMsgGCTrading_TradeChatMsg = 1511
EMsgGCTrading_ConfirmOffer = 1512
EMsgGCTrading_TradeTypingChatMsg = 1513
EMsgGCServerBrowser_FavoriteServer = 1601
EMsgGCServerBrowser_BlacklistServer = 1602
EMsgGCServerRentalsBase = 1700
EMsgGCItemPreviewCheckStatus = 1701
EMsgGCItemPreviewStatusResponse = 1702
EMsgGCItemPreviewRequest = 1703
EMsgGCItemPreviewRequestResponse = 1704
EMsgGCItemPreviewExpire = 1705
EMsgGCItemPreviewExpireNotification = 1706
EMsgGCItemPreviewItemBoughtNotification = 1707
EMsgGCDev_NewItemRequest = 2001
EMsgGCDev_NewItemRequestResponse = 2002
EMsgGCDev_PaintKitDropItem = 2003
EMsgGCStoreGetUserData = 2500
EMsgGCStoreGetUserDataResponse = 2501
EMsgGCStorePurchaseInit_DEPRECATED = 2502
EMsgGCStorePurchaseInitResponse_DEPRECATED = 2503
EMsgGCStorePurchaseFinalize = 2504
EMsgGCStorePurchaseFinalizeResponse = 2505
EMsgGCStorePurchaseCancel = 2506
EMsgGCStorePurchaseCancelResponse = 2507
EMsgGCStorePurchaseQueryTxn = 2508
EMsgGCStorePurchaseQueryTxnResponse = 2509
EMsgGCStorePurchaseInit = 2510
EMsgGCStorePurchaseInitResponse = 2511
EMsgGCBannedWordListRequest = 2512
EMsgGCBannedWordListResponse = 2513
EMsgGCToGCBannedWordListBroadcast = 2514
EMsgGCToGCBannedWordListUpdated = 2515
EMsgGCToGCDirtySDOCache = 2516
EMsgGCToGCDirtyMultipleSDOCache = 2517
EMsgGCToGCUpdateSQLKeyValue = 2518
EMsgGCToGCIsTrustedServer = 2519
EMsgGCToGCIsTrustedServerResponse = 2520
EMsgGCToGCBroadcastConsoleCommand = 2521
EMsgGCServerVersionUpdated = 2522
EMsgGCApplyAutograph = 2523
EMsgGCToGCWebAPIAccountChanged = 2524
EMsgGCRequestAnnouncements = 2525
EMsgGCRequestAnnouncementsResponse = 2526
EMsgGCRequestPassportItemGrant = 2527
EMsgGCClientVersionUpdated = 2528
EMsgGCAdjustItemEquippedStateMulti = 2529
class csgo.proto_enums.EGCMsgResponse
EGCMsgResponseOK = 0
EGCMsgResponseDenied = 1
EGCMsgResponseServerError = 2
EGCMsgResponseTimeout = 3
EGCMsgResponseInvalid = 4
EGCMsgResponseNoMatch = 5
EGCMsgResponseUnknownError = 6
EGCMsgResponseNotLoggedOn = 7
EGCMsgFailedToCreate = 8
EGCMsgLimitExceeded = 9
EGCMsgCommitUnfinalized = 10
class csgo.proto_enums.EGCSystemMsg
EGCMsgInvalid = 0
EGCMsgMulti = 1
EGCMsgGenericReply = 10
EGCMsgSystemBase = 50
EGCMsgAchievementAwarded = 51
EGCMsgConCommand = 52
EGCMsgStartPlaying = 53
EGCMsgStopPlaying = 54
EGCMsgStartGameserver = 55
EGCMsgStopGameserver = 56
EGCMsgWGRequest = 57
EGCMsgWGResponse = 58
EGCMsgGetUserGameStatsSchema = 59
EGCMsgGetUserGameStatsSchemaResponse = 60
EGCMsgGetUserStatsDEPRECATED = 61
EGCMsgGetUserStatsResponse = 62
EGCMsgAppInfoUpdated = 63
EGCMsgValidateSession = 64
EGCMsgValidateSessionResponse = 65
EGCMsgLookupAccountFromInput = 66
EGCMsgSendHTTPRequest = 67
EGCMsgSendHTTPRequestResponse = 68
EGCMsgPreTestSetup = 69
EGCMsgRecordSupportAction = 70
EGCMsgGetAccountDetails_DEPRECATED = 71
EGCMsgReceiveInterAppMessage = 73
EGCMsgFindAccounts = 74
EGCMsgPostAlert = 75
EGCMsgGetLicenses = 76
EGCMsgGetUserStats = 77
EGCMsgGetCommands = 78
EGCMsgGetCommandsResponse = 79
EGCMsgAddFreeLicense = 80
EGCMsgAddFreeLicenseResponse = 81
EGCMsgGetIPLocation = 82
EGCMsgGetIPLocationResponse = 83
EGCMsgSystemStatsSchema = 84
EGCMsgGetSystemStats = 85
EGCMsgGetSystemStatsResponse = 86
EGCMsgSendEmail = 87
EGCMsgSendEmailResponse = 88
EGCMsgGetEmailTemplate = 89
EGCMsgGetEmailTemplateResponse = 90
EGCMsgGrantGuestPass = 91
EGCMsgGrantGuestPassResponse = 92
EGCMsgGetAccountDetails = 93
EGCMsgGetAccountDetailsResponse = 94
EGCMsgGetPersonaNames = 95
EGCMsgGetPersonaNamesResponse = 96
EGCMsgMultiplexMsg = 97
EGCMsgMultiplexMsgResponse = 98
EGCMsgWebAPIRegisterInterfaces = 101
EGCMsgWebAPIJobRequest = 102
EGCMsgWebAPIJobRequestHttpResponse = 104
EGCMsgWebAPIJobRequestForwardResponse = 105
EGCMsgMemCachedGet = 200
EGCMsgMemCachedGetResponse = 201
EGCMsgMemCachedSet = 202
EGCMsgMemCachedDelete = 203
EGCMsgMemCachedStats = 204
EGCMsgMemCachedStatsResponse = 205
EGCMsgMasterSetDirectory = 220
EGCMsgMasterSetDirectoryResponse = 221
EGCMsgMasterSetWebAPIRouting = 222
EGCMsgMasterSetWebAPIRoutingResponse = 223
EGCMsgMasterSetClientMsgRouting = 224
EGCMsgMasterSetClientMsgRoutingResponse = 225
EGCMsgSetOptions = 226
EGCMsgSetOptionsResponse = 227
EGCMsgSystemBase2 = 500
EGCMsgGetPurchaseTrustStatus = 501
EGCMsgGetPurchaseTrustStatusResponse = 502
EGCMsgUpdateSession = 503
EGCMsgGCAccountVacStatusChange = 504
EGCMsgCheckFriendship = 505
EGCMsgCheckFriendshipResponse = 506
EGCMsgGetPartnerAccountLinkResponse = 508
EGCMsgDPPartnerMicroTxns = 512
EGCMsgDPPartnerMicroTxnsResponse = 513
EGCMsgVacVerificationChange = 518
EGCMsgAccountPhoneNumberChange = 519
EGCMsgInviteUserToLobby = 523
EGCMsgGetGamePersonalDataCategoriesRequest = 524
EGCMsgGetGamePersonalDataCategoriesResponse = 525
EGCMsgGetGamePersonalDataEntriesRequest = 526
EGCMsgGetGamePersonalDataEntriesResponse = 527
EGCMsgTerminateGamePersonalDataEntriesRequest = 528
EGCMsgTerminateGamePersonalDataEntriesResponse = 529
class csgo.proto_enums.EGCToGCMsg
EGCToGCMsgMasterAck = 150
EGCToGCMsgMasterAckResponse = 151
EGCToGCMsgRouted = 152
EGCToGCMsgRoutedReply = 153
EMsgUpdateSessionIP = 154
EMsgRequestSessionIP = 155
EMsgRequestSessionIPResponse = 156
EGCToGCMsgMasterStartupComplete = 157
class csgo.proto_enums.ESOMsg
Create = 21
Update = 22
Destroy = 23
CacheSubscribed = 24
CacheUnsubscribed = 25
UpdateMultiple = 26
CacheSubscriptionCheck = 27
CacheSubscriptionRefresh = 28
class csgo.proto_enums.EUnlockStyle
UnlockStyle_Succeeded = 0
UnlockStyle_Failed_PreReq = 1
UnlockStyle_Failed_CantAfford = 2
UnlockStyle_Failed_CantCommit = 3
UnlockStyle_Failed_CantLockCache = 4
UnlockStyle_Failed_CantAffordAttrib = 5
class csgo.proto_enums.GCClientLauncherType
DEFAULT = 0
PERFECTWORLD = 1
STEAMCHINA = 2
class csgo.proto_enums.GCConnectionStatus
HAVE_SESSION = 0
GC_GOING_DOWN = 1
NO_SESSION = 2
NO_SESSION_IN_LOGON_QUEUE = 3
NO_STEAM = 4

sharecode

csgo.sharecode.decode(code)

Decodes a match share code

Parameters:code (str) – match share code (e.g. CSGO-Ab1cD-xYz23-7bcD9-uVZ23-12aBc)
Raises:ValueError
Returns:dict with matchid, outcomeid and token
Return type:dict
{'matchid': 0,
 'outcomeid': 0,
 'token': 0
 }
csgo.sharecode.encode(matchid, outcomeid, token)

Encodes (matchid, outcomeid, token) to match share code

Parameters:
  • matchid (int) – match id
  • outcomeid (int) – outcome id
  • token (int) – token
Returns:

match share code (e.g. CSGO-Ab1cD-xYz23-7bcD9-uVZ23-12aBc)

Return type:

str

client

Only the most essential features to csgo.client.CSGOClient are found here. Every other feature is inherited from the csgo.features package and it’s submodules.

class csgo.client.CSGOClient(steam_client)

Bases: steam.client.gc.GameCoordinator, csgo.features.FeatureBase

Parameters:steam_client (steam.client.SteamClient) – Instance of the steam client
app_id = 730

enable pretty print of messages in debug logging

launcher = 0

main client app id

current_jobid = 0

launcher type (used for access to PW) See: csgo.enums.GCClientLauncherType

connection_status = 2

True when we have a session with GC

account_id

Account ID of the logged-in user in the steam client

steam_id

steam.steamid.SteamID of the logged-in user in the steam client

wait_msg(event, timeout=None, raises=None)

Wait for a message, similiar to wait_event()

Parameters:
  • event (ECsgoGCMsg or job id) – event id
  • timeout (int) – seconds to wait before timeout
  • raises (bool) – On timeout when False returns None, else raise gevent.Timeout
Returns:

returns a message or None

Return type:

None, or proto message

Raises:

gevent.Timeout

send_job(*args, **kwargs)

Send a message as a job

Exactly the same as send()

Returns:jobid event identifier
Return type:str
send(emsg, data={}, proto=None)

Send a message

Parameters:
  • emsg – Enum for the message
  • data (dict) – data for the proto message
  • proto – (optional) manually specify protobuf, other it’s detected based on emsg
launch()

Launch CSGO and establish connection with the game coordinator

ready event will fire when the session is ready. If the session is lost notready event will fire. Alternatively, connection_status event can be monitored for changes.

exit()

Close connection to CSGO’s game coordinator

features

This package contains all high level features of csgo.client.CSGOClient.

match
class csgo.features.match.Match

Bases: object

request_matchmaking_stats()

Request matchmaking statistics

Response event: matchmaking_stats

Parameters:message (proto message) – CMsgGCCStrike15_v2_MatchmakingGC2ClientHello
request_current_live_games()

Request current live games

Response event: current_live_games

Parameters:message (proto message) – CMsgGCCStrike15_v2_MatchList
request_live_game_for_user(account_id)

Warning

Deprecated. CSGO no longer reponds for this method

Request recent games for a specific user

Parameters:account_id (int) – account id of the user

Response event: live_game_for_user

Parameters:message (proto message) –

CMsgGCCStrike15_v2_MatchList

request_full_match_info(matchid, outcomeid, token)

Request full match info. The parameters can be decoded from a match ShareCode

Parameters:
  • matchid (int) – match id
  • outcomeid (int) – outcome id
  • token (int) – token

Response event: full_match_info

Parameters:message (proto message) –

CMsgGCCStrike15_v2_MatchList

request_recent_user_games(account_id)

Request recent games for a specific user

Parameters:account_id (int) – account id of the user

Response event: recent_user_games

Parameters:message (proto message) –

CMsgGCCStrike15_v2_MatchList

request_watch_info_friends(account_ids, request_id=1, serverid=0, matchid=0)

Request watch info for friends

Parameters:
  • account_ids (list) – list of account ids
  • request_id (int) – request id, used to match reponse with request (default: 1)
  • serverid (int) – server id
  • matchid (int) – match id

Response event: watch_info

Parameters:message (proto message) – CMsgGCCStrike15_v2_WatchInfoUsers
player
class csgo.features.player.Player

Bases: object

ranks_map = {0: 'Not Ranked', 1: 'Silver I', 2: 'Silver II', 3: 'Silver III', 4: 'Silver IV', 5: 'Silver Elite', 6: 'Silver Elite Master', 7: 'Gold Nova I', 8: 'Gold Nova II', 9: 'Gold Nova III', 10: 'Gold Nova Master', 11: 'Master Guardian I', 12: 'Master Guardian II', 13: 'Master Guardian Elite', 14: 'Distinguished Master Guardian', 15: 'Legendary Eagle', 16: 'Legendary Eagle Master', 17: 'Supreme Master First Class', 18: 'The Global Elite'}

dict mapping rank id to name

wingman_ranks_map = {0: 'Not Ranked', 1: 'Silver I', 2: 'Silver II', 3: 'Silver III', 4: 'Silver IV', 5: 'Silver Elite', 6: 'Silver Elite Master', 7: 'Gold Nova I', 8: 'Gold Nova II', 9: 'Gold Nova III', 10: 'Gold Nova Master', 11: 'Master Guardian I', 12: 'Master Guardian II', 13: 'Master Guardian Elite', 14: 'Distinguished Master Guardian', 15: 'Legendary Eagle', 16: 'Legendary Eagle Master', 17: 'Supreme Master First Class', 18: 'The Global Elite'}

dict mapping wingman rank id to name

dangerzone_ranks_map = {0: 'Hidden', 1: 'Lab Rat I', 2: 'Lab Rat II', 3: 'Sprinting Hare I', 4: 'Sprinting Hare II', 5: 'Wild Scout I', 6: 'Wild Scout II', 7: 'Wild Scout Elite', 8: 'Hunter Fox I', 9: 'Hunter Fox II', 10: 'Hunter Fox II', 11: 'Hunter Fox Elite', 12: 'Timber Wolf', 13: 'Ember Wolf', 14: 'Wildfire Wolf', 15: 'The Howling Alpha'}

dict mapping dangerzone rank id to name

levels_map = {0: 'Not Recruited', 1: 'Recruit', 2: 'Private', 3: 'Private', 4: 'Private', 5: 'Corporal', 6: 'Corporal', 7: 'Corporal', 8: 'Corporal', 9: 'Sergeant', 10: 'Sergeant', 11: 'Sergeant', 12: 'Sergeant', 13: 'Master Sergeant', 14: 'Master Sergeant', 15: 'Master Sergeant', 16: 'Master Sergeant', 17: 'Sergeant Major', 18: 'Sergeant Major', 19: 'Sergeant Major', 20: 'Sergeant Major', 21: 'Lieutenant', 22: 'Lieutenant', 23: 'Lieutenant', 24: 'Lieutenant', 25: 'Captain', 26: 'Captain', 27: 'Captain', 28: 'Captain', 29: 'Major', 30: 'Major', 31: 'Major', 32: 'Major', 33: 'Colonel', 34: 'Colonel', 35: 'Colonel', 36: 'Brigadier General', 37: 'Major General', 38: 'Lieutenant General', 39: 'General', 40: 'Global General'}

dict mapping level to name

request_player_profile(account_id, request_level=32)

Request player profile

Parameters:
  • account_id (int) – account id
  • request_level (int) – no clue what this is used for; if you do, please make pull request

Response event: player_profile

Parameters:message (proto message) – CMsgGCCStrike15_v2_MatchmakingGC2ClientHello
items
class csgo.features.items.Items

Bases: object

request_preview_data_block(s, a, d, m)

Request item preview data block

The parameters can be taken from inspect links either from an inventory or market. The market has the m paramter, while the inventory one has s. Set the missing one to 0. Example inpsect links:

steam://rungame/730/765xxxxxxxxxxxxxx/+csgo_econ_action_preview%20S11111111111111111A2222222222D33333333333333333333``
steam://rungame/730/765xxxxxxxxxxxxxx/+csgo_econ_action_preview%20M444444444444444444A2222222222D33333333333333333333``
Parameters:
  • s (int) – steam id of owner (set to 0 if not available)
  • a (int) – item id
  • d (int) – UNKNOWN
  • m (int) – market id (set to 0 if not available)

Response event: item_data_block

Parameters:message (proto message) – CEconItemPreviewDataBlock
sharedobjects

Essentially a dict containing shared object caches. The objects are read-only, so don’t change any values. The instance reference of individual objects will remain the same thought their lifetime. Individual objects can be accessed via their key, if they have one.

Note

Some cache types don’t have a key and only hold one object instance. Then only the the cache type is needed to access it. (e.g. CSOEconGameAccountClient)

csgo_client.socache[ESOType.CSOEconItem]          # dict with item objects, key = item id
csgo_client.socache[ESOType.CSOEconItem][123456]  # item object

csgo_client.socache[ESOType.CSOEconGameAccountClient]  # returns a CSOEconGameAccountClient object

Events will be fired when individual objects are updated. Event key is a tuple` in the following format: (event, cache_type).

The available events are new, updated, and removed. Each event has a single parameter, which is the object instance. Even when removed, there is object instance returned, usually only with the key field filled.

@csgo_client.socache.on(('new', ESOType.CSOEconItem))
def got_a_new_item(obj):
    print "Got a new item! Yay"
    print obj

# access the item via socache at any time
print csgo_client.socache[ESOType.CSOEconItem][obj.id]
csgo.features.sharedobjects.find_so_proto(type_id)

Resolves proto massage for given type_id

Parameters:type_id (csgo.enums.ESOType) – SO type
Returns:proto message or None
class csgo.features.sharedobjects.NO_KEY
csgo.features.sharedobjects.get_so_key_fields(desc)
csgo.features.sharedobjects.get_key_for_object(obj)
class csgo.features.sharedobjects.SOBase

Bases: object

class csgo.features.sharedobjects.SOCache(csgo_client, logger_name)

Bases: eventemitter.EventEmitter, dict

class ESOType

Bases: enum.IntEnum

CSOAccountSeasonalOperation = 41
CSOEconCoupon = 45
CSOEconDefaultEquippedDefinitionInstanceClient = 43
CSOEconGameAccountClient = 7
CSOEconItem = 1
CSOEconItemDropRateBonus = 38
CSOEconItemEventTicket = 40
CSOItemRecipe = 5
CSOPersonaDataPublic = 2
CSOQuestProgress = 46
emit(event, *args)

Emit event with some arguments

Parameters:
  • event (any type) – event identifier
  • args – any or no arguments

Indices and tables