Skip to main content

Python Source Server Query Library

A Python package for communicating with a Source Engine Server over UDP

I push changes to the master branch whenever I finish a session of working on this. If you want the absolute latest version, download the code and use it manually, otherwise install through pip for the latest version I class as stable enough to use in your own projects.

Untested

  • Split package payload decompression
  • Split package size attribute detection
  • CS:GO servers with host_players_show set to 1 as I'm currently unable to find a server that uses this
  • Getting the players on a server running The Ship when someone is in the process of joining, as it relies on the count returned with the response packet, which may or may not differ from the actual number of players when someone is joining. (This descrepancy has not yet been observed on other servers despite the Valve dev wiki stating otherwise)

Installation

pip install sourceserver

Basic Usage

A SourceServer object acts as a connection to a Source engine server, with its own socket.
To instantiate a new SourceServer object, simply pass it a connection string in the form ipv4:port, the object will attempt to get the server's info, and if the connection fails after max retries, raises a SourceError.
Note, all errors that are expected are raised as SourceError, which marks the server as closed, but does not actually close the socket so the connection can be re-established.
The information regarding a server is retrieved each time you access the .info property, and is a dictionary in the form "info_type": "value".

A MasterServer object lets you query the Steam master servers, see the wiki for details

Example

>>> from sourceserver.sourceserver import SourceServer
>>> srv = SourceServer("89.35.29.5:27085")
Source Server @ 89.35.29.5:27085 | Connecting...
Source Server @ 89.35.29.5:27085 | Successfully established connection to server
>>> print(srv.info["game"]) 
Trouble in Terrorist Town
>>> print(srv.ping()) 
30.0
>>> print(srv.ping(2)) 
27.03
>>> count, players = srv.getPlayers()
>>> print(count)  
6
>>> print(players[0])
(0, 'Nbx3k', 17, 9938.7001953125)

Discord Server

https://discord.gg/aKDNstq

Discord Bot

https://github.com/Derpius/pythonsourceserverdiscordbot

License

GNU General Public License v3.0

Metadata

Release files for sourceserver 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sourceserver 0.10.0
File Size Uploaded
sourceserver-0.10.0.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sourceserver 0.10.0
File Interpreter ABI Platform
sourceserver-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / sourceserver-0.10.0.tar.gz

Download URL sourceserver-0.10.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
00f13edbe04ebb28c60592aea6c2c48a0c402c14a983c6076a0a3bf38523df2f
BLAKE2b-256 checksum
How to use checksums
ea7ae8fafc43e2fe232b83f286bb37d0816f18df41d5e4e1c392d7f8dc55c941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / sourceserver-0.10.0-py3-none-any.whl

Download URL sourceserver-0.10.0-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76a05da43a66fd710041c5b58225a83b17833ef7f35dfd89cff2656962be2ee7
BLAKE2b-256 checksum
How to use checksums
910d6a0f946f21a56b559b143dd13d8ef79fa2ca2d2094e9d4a394946a60ff9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page