Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mick88/samp-client
GTA SA-MP API client library for Python
https://github.com/mick88/samp-client
api api-client python python-library python2 python3 python36 rcon rcon-client sa-mp
Last synced: 11 days ago
JSON representation
GTA SA-MP API client library for Python
- Host: GitHub
- URL: https://github.com/mick88/samp-client
- Owner: mick88
- License: mit
- Created: 2017-06-11T22:11:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T21:16:58.000Z (5 months ago)
- Last Synced: 2024-12-14T13:23:47.179Z (19 days ago)
- Topics: api, api-client, python, python-library, python2, python3, python36, rcon, rcon-client, sa-mp
- Language: Python
- Size: 84 KB
- Stars: 28
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
- License: LICENSE
Awesome Lists containing this project
README
# GTA SA-MP client
## RCON and query client library for Python
A modern Python library for querying and managing SA-MP servers.
Supported Python version 3.6 or newer.
If you require support for Python 2.7, install 2.1 version of the package.### Installation
```bash
pip install samp-client
```### Usage
The library can be easily interfaced using a single `SampClient` class:```python
from samp_client.client import SampClientwith SampClient(address='localhost', port=7777) as client:
print(client.get_server_info())
```The library also allows you to run RCON commands as well as queries:
```python
from samp_client.client import SampClientwith SampClient(address='localhost', port=7777, rcon_password='password') as client:
client.rcon_cmdlist()
```Query and RCON responses are parsed into native Python structures:
```python
from samp_client.client import SampClientwith SampClient(address='localhost', port=7777, rcon_password='password') as client:
info = client.get_server_info()
print(info)
# ServerInfo(password=True, players=9, max_players=100, hostname='Convoy Trucking', gamemode='Convoy Trucking 3.1.1', language='English')
print(info.gamemode)
# 'Convoy Trucking 3.1.1'
print(client.rcon_get_hostname())
# ServerVar(name='hostname', value='Convoy Trucking', read_only=False)
print(client.rcon_players()[0].ping)
# 26
```### Examples
Folder `example/` contains usage example of the library### Running tests
To run tests:
```bash
python -m unittest discover -v
```