UNOFFICIAL Lightweight Python client for the OpenShock API
Project description
OpenShock Python 
Unofficial, lightweight helper for the OpenShock API. Designed to be easy to use for anyone, with optional advanced controls for developers.
What this project offers
- Simple Python client to list devices/shockers and send actions (shock, vibrate, beep).
- Full coverage of the OpenShock v1 and v2 APIs: hubs, shockers, shares, tokens, logs, sessions and account endpoints.
- Matching synchronous and asynchronous clients with the same method names.
- Optional CLI for quick checks without writing code.
- Keeps your API key in memory only; the CLI can store it securely via your system keyring.
License TL;DR (see full LICENSE.md for complete terms)
- Free for non-commercial, ethical use; you may study, modify, and share it.
- You can include it in other open-source projects as a separate library component.
- You must share source code for adaptations you distribute.
- No commercial use, monetization, or commercial AI training without a separate license.
- Adaptations must keep this license (unless used as a distinct component as allowed in Section 6A).
Quick start (Python)
-
Install the library:
pip install Nanashi-OpenShockPY
-
Get your OpenShock API key from your account dashboard.
-
Create a client with a User-Agent and your API key:
from OpenShockPY import OpenShockClient, OpenShockPYError client = OpenShockClient( api_key="YOUR_API_KEY", user_agent="YourAppName/YourAppVersion", )
-
List devices or send an action:
print(client.list_devices()) client.shock("YOUR_SHOCKER_ID", intensity=50, duration=1000) # Or send to all shockers at once using "all" as the shocker ID client.shock("all", intensity=50, duration=1000) # Alternatively, use the explicit *_all methods client.shock_all(intensity=50, duration=1000)
-
(Optional) Use as a context manager for automatic cleanup:
with OpenShockClient(api_key="YOUR_API_KEY", user_agent="YourAppName/YourAppVersion") as client: client.list_devices() # Session is automatically closed when the block exits
Note: The client also cleans up automatically when garbage collected, so the context manager is optional.
Optional CLI (no coding needed)
Install with CLI support:
pip install "Nanashi-OpenShockPY[cli]"
Store your API key securely, then list devices:
openshock login --api-key YOUR_KEY
openshock devices
Send a command (use a shocker ID, not a device ID):
openshock shock --shocker-id YOUR_SHOCKER_ID --intensity 40 --duration 1500
Or send a command to all shockers at once:
openshock shock --shocker-id all --intensity 40 --duration 1500
Other commands: shockers, vibrate, beep, stop, pause, unpause, logs, whoami, tokens, logout.
The CLI automatically sets an appropriate User-Agent. If the openshock command is not on your PATH, every example also works as python -m OpenShockPY.cli <command>.
Async client (opt-in)
If you prefer non-blocking operation, there is an experimental asynchronous client available: AsyncOpenShockClient.
Install the optional dependencies:
pip install Nanashi-OpenShockPY[async]
Usage:
import asyncio
from OpenShockPY import AsyncOpenShockClient
async def main():
async with AsyncOpenShockClient(api_key="YOUR_API_KEY", user_agent="YourAppName/YourAppVersion") as client:
devices = await client.list_devices()
await client.shock_all(intensity=50, duration=1000)
asyncio.run(main())
⚠️ Experimental / Unsupported: The AsyncOpenShockClient is an opt-in, experimental client provided for convenience. It is not officially supported or fully tested in production scenarios. Use at your own risk — APIs, behavior, or method signatures may change without notice. If stability and long-term support are required, prefer the synchronous OpenShockClient.
Installation options
- Library only (most people):
pip install Nanashi-OpenShockPY - Library + CLI extras (adds keyring):
pip install "Nanashi-OpenShockPY[cli]" - Library + Async extras (adds httpx, pytest-asyncio, respx):
pip install "Nanashi-OpenShockPY[async]" - Library + all extras:
pip install "Nanashi-OpenShockPY[all]" - Development/editable install from this repo:
pip install -e .(orpip install -e ".[cli]"for CLI,pip install -e ".[all]"for all extras)
Responsible use and licensing
- This project is for non-commercial, ethical use only. Commercial use requires a separate license.
- Respect local laws and the rights and safety of others when issuing control commands.
- Full terms: LICENSE.md.
Need more detail?
Advanced options, API notes, and developer tips are available in ADVANCED.md.
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 nanashi_openshockpy-0.1.0.0.tar.gz.
File metadata
- Download URL: nanashi_openshockpy-0.1.0.0.tar.gz
- Upload date:
- Size: 37.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ecf8bc708dea85ea9abc5fea2e799a8335fca020971a9874f81175121670269
|
|
| MD5 |
d1f5895f15630089792bf36e33e5c08e
|
|
| BLAKE2b-256 |
204fb424e62e3dc31712854d9fd0d787c455a0e17645ccf41e358c85271c2f03
|
Provenance
The following attestation bundles were made for nanashi_openshockpy-0.1.0.0.tar.gz:
Publisher:
python-publish.yml on NanashiTheNameless/OpenShockPY
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nanashi_openshockpy-0.1.0.0.tar.gz -
Subject digest:
3ecf8bc708dea85ea9abc5fea2e799a8335fca020971a9874f81175121670269 - Sigstore transparency entry: 2229098972
- Sigstore integration time:
-
Permalink:
NanashiTheNameless/OpenShockPY@be21c8f2dc634027e270d70e48c56fbe1d60df09 -
Branch / Tag:
refs/tags/0.1.0.0 - Owner: https://github.com/NanashiTheNameless
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@be21c8f2dc634027e270d70e48c56fbe1d60df09 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nanashi_openshockpy-0.1.0.0-py3-none-any.whl.
File metadata
- Download URL: nanashi_openshockpy-0.1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08cb6b36ff3c04d1575fc805548092167d65cebf69807401bef70cc38f6b45bc
|
|
| MD5 |
399059be2bb8fe488d596addd8de2fc2
|
|
| BLAKE2b-256 |
7af61047152db497e5852c81caed4e26ee17c847ccfb5356ad4d625fdebdd979
|
Provenance
The following attestation bundles were made for nanashi_openshockpy-0.1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on NanashiTheNameless/OpenShockPY
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nanashi_openshockpy-0.1.0.0-py3-none-any.whl -
Subject digest:
08cb6b36ff3c04d1575fc805548092167d65cebf69807401bef70cc38f6b45bc - Sigstore transparency entry: 2229099439
- Sigstore integration time:
-
Permalink:
NanashiTheNameless/OpenShockPY@be21c8f2dc634027e270d70e48c56fbe1d60df09 -
Branch / Tag:
refs/tags/0.1.0.0 - Owner: https://github.com/NanashiTheNameless
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@be21c8f2dc634027e270d70e48c56fbe1d60df09 -
Trigger Event:
release
-
Statement type: