A Python library to interface the Game State Integration in Dota 2.
The dota2gsipy library facilitates the integration of Valve's Dota 2 game state into Python applications. It listens for HTTP POST requests from the game on a specific address and port, parses the game state, and makes it available for use in the application.
After starting the GSIServer
instance, it will continuously listen for incoming HTTP requests. Upon a received request, the contents will be parsed into a GameState
object.
Game State Integration has bit been officially released for Dota 2. However, it is already possible access some of their information provided by the game. GSI has been available for Counter-Strike: Global Offensive and it is really similiar from the current Dota 2 GSI version. Learn more about Counter-Strike Game State Integration here.
Using pip:
pip install dota2gsipy==0.1.0
- Create a custom
gamestate_integration_*.cfg
ingame/dota/cfg/gamestate_integration/
, for example:
gamestate_integration_test.cfg
"Dota 2 Integration Configuration"
{
"uri" "http://localhost:4000/"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.1"
"heartbeat" "30.0"
"auth"
{
"token" "TOKENHERE"
}
"data"
{
"provider" "1"
"map" "1"
"player" "1"
"hero" "1"
"abilities" "1"
"items" "1"
}
}
- Create a
GSIServer
instance providing address, port and your token defined by the GSI configuration file.
import logging
from dota2gsipy.server import GSIServer
logging.basicConfig(level=logging.INFO)
server = GSIServer(("127.0.0.1", 4000),"TOKENHERE")
server.start_server()
Full list of item names can be found here and a full list of heroes can be located here.
import logging
from dota2gsipy.server import GSIServer
logging.basicConfig(level=logging.INFO)
server = GSIServer(("127.0.0.1", 4000),"TOKENHERE")
server.start_server()
while True:
print(f'Gold: {server.game_state.player.gold}')
print(f'Name: {server.game_state.player.name}')
print(f'Hero name: {server.game_state.hero.name}')
print(f'Pos: {server.game_state.hero.pos}')
print(f'Talents: {server.game_state.hero.talents}')
In case the payload does not contain the requested information, this value will be returned as None
.
antonpup for his C# Game State Integration library. mdhedelund for a CS:GO GSI Python library.