The official OpenShock Python SDK to integrate with an OpenShock backend easily
Project description
OpenShock Python SDK
The official OpenShock Python SDK to integrate with an OpenShock backend easily. Provides a typed REST API client with planned support for live WebSocket connections.
Install
pip install openshock
Quick start
from openshock import OpenShockClient
client = OpenShockClient(api_token="your-api-token")
# Get backend info
info = client.meta.backend_info()
print(f"OpenShock {info.version}")
# List your shockers
shockers = client.shockers.list_own()
# Send a vibrate command
from openshock import Control
client.shockers.control([
Control(id="shocker-uuid", type="Vibrate", intensity=50, duration=1000)
])
client.close()
Or use as a context manager:
with OpenShockClient(api_token="your-api-token") as client:
stats = client.meta.online_stats()
print(f"Devices online: {stats.devices_online}")
Resources
| Resource | Description | Example |
|---|---|---|
client.meta |
Backend info and stats | client.meta.backend_info() |
client.account |
User info and API tokens | client.account.user_self() |
client.devices |
Hub (device) management | client.devices.list() |
client.shockers |
Shocker CRUD, control, logs | client.shockers.control(...) |
client.shares |
Public share links and codes | client.shares.list_public() |
client.user_shares |
User-to-user shares (V2) | client.user_shares.get() |
client.sessions |
Login session management | client.sessions.list() |
For hub/device endpoints, use OpenShockHubClient:
from openshock import OpenShockHubClient
hub = OpenShockHubClient(hub_token="device-token")
lcg = hub.hub.assign_lcg()
print(f"Connect to {lcg.host}:{lcg.port}")
Authentication
Two client types for two auth schemes:
OpenShockClient(api_token=...)— User API token (OpenShockTokenheader)OpenShockHubClient(hub_token=...)— Device token (DeviceTokenheader)
Create API tokens at openshock.app under Settings > API Tokens.
Typed models
All responses are parsed into typed dataclasses:
from openshock import (
BackendInfo, Stats, User, Token, Device, Shocker,
ShockerPermissions, ShockerLimits, ShockerLog, Control,
Session, PublicShare, UserShares, ShareInvite, PauseReason,
)
Self-hosting
To connect to a self-hosted instance:
client = OpenShockClient(
api_token="your-token",
base_url="https://api.your-instance.com",
)
Development
git clone https://github.com/OpenShock/SDK.Python.git
cd SDK.Python
pip install -e ".[dev]"
# Format
ruff format .
# Lint
ruff check .
# Type check
mypy openshock/
# Test
pytest
License
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 Distribution
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 openshock-0.1.0b1.tar.gz.
File metadata
- Download URL: openshock-0.1.0b1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2131188ecbd930be29783c070c22e9be96305fb769f4308bb14036333c94b135
|
|
| MD5 |
47f522090b0eff716764914fdd507a35
|
|
| BLAKE2b-256 |
cd00efa05d327975330e8146d61959d7511be9880db99ecd8370cbdd77687843
|
Provenance
The following attestation bundles were made for openshock-0.1.0b1.tar.gz:
Publisher:
publish.yml on OpenShock/SDK.Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openshock-0.1.0b1.tar.gz -
Subject digest:
2131188ecbd930be29783c070c22e9be96305fb769f4308bb14036333c94b135 - Sigstore transparency entry: 1176317190
- Sigstore integration time:
-
Permalink:
OpenShock/SDK.Python@11ca3ee723b2588bd2726e66c5fbbb5c515264df -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/OpenShock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11ca3ee723b2588bd2726e66c5fbbb5c515264df -
Trigger Event:
push
-
Statement type:
File details
Details for the file openshock-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: openshock-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df0107a1254c6a4abb2bd613b193c41eca7b06de1cf7983939887666515a066a
|
|
| MD5 |
ce598c7a4c9a47dd02621634bee5c49f
|
|
| BLAKE2b-256 |
0f6fd0b7a77430ecdd64e20b368ba5a7c9067d350fe0b0f01b80577db338f3fb
|
Provenance
The following attestation bundles were made for openshock-0.1.0b1-py3-none-any.whl:
Publisher:
publish.yml on OpenShock/SDK.Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openshock-0.1.0b1-py3-none-any.whl -
Subject digest:
df0107a1254c6a4abb2bd613b193c41eca7b06de1cf7983939887666515a066a - Sigstore transparency entry: 1176317250
- Sigstore integration time:
-
Permalink:
OpenShock/SDK.Python@11ca3ee723b2588bd2726e66c5fbbb5c515264df -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/OpenShock
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11ca3ee723b2588bd2726e66c5fbbb5c515264df -
Trigger Event:
push
-
Statement type: