Skip to main content

UNOFFICIAL Lightweight Python client for the OpenShock API

Project description

OpenShock Python Ask DeepWiki

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).
  • 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)

  1. Install the library:

    pip install Nanashi-OpenShockPY
    
  2. Get your OpenShock API key from your account dashboard.

  3. Create a client with a User-Agent and your API key:

    from OpenShockPY import OpenShockClient
    
    client = OpenShockClient(
        api_key="YOUR_API_KEY",
        user_agent="YourAppName/YourAppVersion",
    )
    
  4. 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
    client.shock_all(intensity=50, duration=1000)
    
  5. (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:

python -m OpenShockPY.cli login --api-key YOUR_KEY
python -m OpenShockPY.cli devices

Send a command (use a shocker ID, not a device ID):

python -m OpenShockPY.cli shock --shocker-id YOUR_SHOCKER_ID --intensity 40 --duration 1500

Or send a command to all shockers at once:

python -m OpenShockPY.cli shock --shocker-id all --intensity 40 --duration 1500

The CLI automatically sets an appropriate User-Agent.

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 . (or pip 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanashi_openshockpy-0.0.1.2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanashi_openshockpy-0.0.1.2-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file nanashi_openshockpy-0.0.1.2.tar.gz.

File metadata

  • Download URL: nanashi_openshockpy-0.0.1.2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.9

File hashes

Hashes for nanashi_openshockpy-0.0.1.2.tar.gz
Algorithm Hash digest
SHA256 75493f724e47a082f46a06d48e06361ecc20fac23be09172c5ec117616685096
MD5 e4436ed8f950d57acc0317fbd7ebf8bc
BLAKE2b-256 b9c50afc13c2c26b3b4695a5a10d6c63bfae868ada85a62d2d57c7142929b972

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanashi_openshockpy-0.0.1.2.tar.gz:

Publisher: python-publish.yml on NanashiTheNameless/OpenShockPY

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nanashi_openshockpy-0.0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nanashi_openshockpy-0.0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94dd9e6b1a39561d5923259e380fb4a8251c4bb5d40a84c1f64378518e207a1f
MD5 a268920a5ec669e5d17fcb6cf94a43e1
BLAKE2b-256 4e7e8b1016aebb4a0333df07ed4c80fa370800aef4fd5d7ef22e96e3a2e255ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for nanashi_openshockpy-0.0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on NanashiTheNameless/OpenShockPY

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page