Python wrapper for the Scorbit SDK (pinball scoring platform)
Project description
Scorbit SDK - Python 3.6+
Pure-Python wrapper for the Scorbit SDK C library. Works on Python 3.6+ with no compilation: it uses ctypes against the stable C ABI.
For Python 2.7, use
wrappers/python27(pip install scorbit-py2on PyPI).
Native SDK required
pip install scorbit installs only the Python wrapper (PyPI wheel). You must also install the native shared library (libscorbit_sdk.so / .dylib / .dll) for the same version from GitHub releases (for example scorbit_sdk-1.99.66-arm64_u18.deb or .tar.gz). If the library is missing, import scorbit prints a version-matched release URL and suggested filenames for your platform.
Prerequisites
Install the Scorbit SDK shared library on the system. The wrapper loads it in this order:
- Directory from
SCORBIT_SDK_PATH /opt/scorbit/libwhen using official Linux packages- Normal dynamic linker paths (
LD_LIBRARY_PATH,DYLD_LIBRARY_PATH,/usr/local/lib, etc.)
| Platform | Library file |
|---|---|
| Linux | libscorbit_sdk.so |
| macOS | libscorbit_sdk.dylib |
| Windows | scorbit_sdk.dll |
Installation
pip install scorbit
Then install the native SDK from the matching release, for example 1.99.66, and use the .deb or .tar.gz for your architecture and ABI tag (see the root README).
From this repository:
cd wrappers/python
pip install .
Building a wheel from the SDK repo
make python runs scripts/python-build.sh. By default the wheel is built in Docker using dilshodm/python-builder:<tag> (DOCKER_RELEASE in the repo root; built from the gcc-builder repo), via docker_build_wheel in scripts/_common.sh. Use SCORBIT_PYTHON_NO_DOCKER=1, run already inside a container (/.dockerenv), or skip Docker when it is unavailable to build with the current host Python instead.
Setting the library path
# Linux / macOS
export SCORBIT_SDK_PATH=/opt/scorbit/lib
# Windows (PowerShell)
$env:SCORBIT_SDK_PATH = "C:\scorbit\lib"
Quick start
Set set_event_callback (and optional key callbacks) on Config before create_game_state. Use a with block or call gs.destroy() when done (see examples/python_example/main.py).
import os
import scorbit
config = scorbit.Config()
config.set_provider("myprovider")
config.set_machine_id(4419)
config.set_game_code_version("1.0.0")
config.set_encrypted_key("<your-encrypted-key>")
def on_event(event):
if event.type == scorbit.EventType.GameStartRequested:
players = event.get_game_start_requested()
print(f"Game start requested with {players} player(s)")
elif event.type == scorbit.EventType.PlayersUpdated:
players = event.get_players_updated()
for num, info in players.items():
print(f" Player {num}: {info.preferred_name}")
config.set_event_callback(on_event)
config.set_save_key_callback(lambda key: open("device_key.json", "w").write(key))
config.set_load_key_callback(
lambda: open("device_key.json").read()
if os.path.exists("device_key.json") else ""
)
with scorbit.create_game_state(config) as gs:
gs.set_capabilities(scorbit.Capability.StartGame | scorbit.Capability.CreditDrop)
gs.set_game_started(scorbit.GameStartOrigin.StartButton)
gs.set_score(1, 42000, feature=2)
gs.set_current_ball(1)
gs.add_mode("MB:Multiball")
gs.commit()
gs.set_game_finished()
API reference
Enums
| Enum | Values |
|---|---|
Error |
Success, Unknown, AuthFailed, NotPaired, ApiError, FileError |
AuthStatus |
NotAuthenticated, Authenticating, AuthenticatedCheckingPairing, AuthenticatedUnpaired, AuthenticatedPaired, AuthenticationFailed |
GameStartOrigin |
StartButton, FromLobby |
Capability |
StartGame, CreditDrop (combine with ` |
EventType |
GameStartRequested, CreditsAddRequested, CreditsStatusRequested, ConfigReceived, PlayersUpdated, PlayerPictureReady |
LogLevel |
Debug, Info, Warn, Error |
Config
Setters return self for chaining.
| Method | Description |
|---|---|
set_provider(name) |
Required. Provider name. |
set_machine_id(id) |
Required. Scorbit machine ID. |
set_game_code_version(ver) |
Required. Game code version string. |
set_encrypted_key(key) |
Auth key (non-TPM). |
set_signer(callback) |
TPM signer: (digest: bytes) -> bytes. |
set_hostname(host) |
"production", "staging", or URL. |
set_uuid(uuid) |
Device UUID (from MAC if omitted). |
set_serial_number(sn) |
Device serial number. |
set_auto_download_player_pics(bool) |
Download profile pictures. |
set_score_features(list, version) |
Score feature names and version. |
set_event_callback(cb) |
(event: Event) -> None. |
set_save_key_callback(cb) |
(key: str) -> None. |
set_load_key_callback(cb) |
() -> str. |
GameState
From scorbit.create_game_state(config). Supports with / __exit__ cleanup.
| Method / property | Description |
|---|---|
set_game_started(origin) |
Start a session. |
set_game_finished() |
End session (auto-commits). |
set_current_ball(ball) |
Ball 1-9. |
set_active_player(player) |
Active player 1-9. |
set_score(player, score, feature=0) |
Set score. |
add_mode(mode) |
Add mode string. |
add_mode_expiring(mode, secs=3) |
Expiring mode. |
remove_mode(mode) |
Remove mode. |
clear_modes() |
Clear all modes. |
commit() |
Push updates to the cloud. |
status |
AuthStatus. |
machine_uuid |
Machine UUID string. |
machine_serial |
Machine serial number (int, unsigned 64-bit; same as TPM / device info). |
pair_deeplink |
Pairing URL. |
request_top_scores(scope, period, since, vpin_filter, cb) |
Async leaderboard. |
request_pair_code(cb) |
Async pairing code. |
request_unpair(cb) |
Async unpair. |
set_capabilities(flags) |
Capability flags. |
set_credits_dropped(n, tx, ok) |
Credit drop report. |
set_credits_status(free, n, max, pricing) |
Credit status. |
download(url, file, ct, cb) |
Async file download. |
download_buffer(url, size, ct, cb) |
Async buffer download. |
destroy() |
Free resources (also from __exit__). |
Event
type is EventType. Helpers return parsed data or None if the type does not match.
| Method | Returns |
|---|---|
get_game_start_requested() |
int (player count) or None |
get_credits_add_requested() |
(int, str) or None |
get_pricing_received() |
PricingInfo or None |
get_config_received() |
JSON str or None |
get_players_updated() |
dict[int, PlayerInfo] or None |
get_player_picture_ready() |
(int, bytes) or None |
PlayerInfo
| Attribute | Description |
|---|---|
id |
Scorbit player ID |
preferred_name |
Display name |
name |
Full name |
initials |
Initials |
picture_url |
Picture URL |
claim_deeplink |
Claim URL (empty slots) |
has_info() |
Whether the slot is claimed |
Logger
If logger callback is registered it will receive log lines from SDK.
def my_logger(message, level, file, line, timestamp):
print(f"[{level.name}] {message}")
scorbit.add_logger_callback(my_logger, max_length=512)
scorbit.reset_logger() # when done
Threading
- C calls release the GIL (
ctypes.CDLL). - C callbacks (events, async results, logger) acquire the GIL via
CFUNCTYPE; you do not manage the GIL yourself. - Callbacks run on SDK threads; guard shared mutable state with
threading.Lock. - An
atexithandler stops callback trampolines during shutdown to avoid crashes.
License
MIT - see the LICENSE file in the repository root.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scorbit-2.0.3-py3-none-any.whl.
File metadata
- Download URL: scorbit-2.0.3-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1deaceb201eb910d50d3795981e355660b9329806f53ab6860d373e64cacc8f
|
|
| MD5 |
92f8c23c11483064a03580a6ebe7400c
|
|
| BLAKE2b-256 |
f4f6777f3f912fc23ec1cf359d93baa52787ffd1b7c1dababb028577134800f5
|
Provenance
The following attestation bundles were made for scorbit-2.0.3-py3-none-any.whl:
Publisher:
release-pypi.yml on scorbit-io/scorbit_sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scorbit-2.0.3-py3-none-any.whl -
Subject digest:
b1deaceb201eb910d50d3795981e355660b9329806f53ab6860d373e64cacc8f - Sigstore transparency entry: 1590900909
- Sigstore integration time:
-
Permalink:
scorbit-io/scorbit_sdk@3b2054978eba945ce86910a56e7786454a16c9eb -
Branch / Tag:
refs/tags/2.0.3 - Owner: https://github.com/scorbit-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@3b2054978eba945ce86910a56e7786454a16c9eb -
Trigger Event:
push
-
Statement type: