Skip to main content

initial beta version

Project description

nikkiServiceBase for Python

Easy-to-use Python client for connecting your service to the nikki.build playground using WebSocket.


What this library offers

  • Simple async WebSocket connection
  • Automatic handling of serviceDef.json + serviceToken.json
  • Strict validation at startup (fail-fast with clear errors)
  • Auto-reconnect (optional)
  • Clean callbacks: onConnect, onConnect, onError, onData
  • Two send methods:
    • await client.send(...) → normal send (raises on rate limit)
    • client.send_nowait(...) → safe for callbacks (never crashes, ignores rate limit)
  • Full size & rate-limit protection (exactly matches platform rules)
  • Production-ready, defensive, and very easy to use

Installation

  1. Install the only dependency:
pip install websockets

Copy the library file into your project as nikki_client.py (or keep it as libBase.py).

Quick Start

import asyncio
import time
from nikki_python.nikki_client import nikkiServiceBase



async def main():

    client = nikkiServiceBase(auto_reconnect=True)

    def onConnect(details):   print(f"✅ CONNECTED → {details}")
    def on_disconnect(details): print(f"❌ DISCONNECTED → {details}")
    def on_error(error):       print(f"⚠️  ERROR → {error}")
    def on_message_handler(data: dict):
        print(f"📨 RECEIVED: {data}")


    client.onConnect = onConnect
    client.onDisconnect = on_disconnect
    client.onError = on_error
    client.onData = on_message_handler

    await client.connect()

    print("📤 Sending 100 test messages (every 2 seconds)...")
    for i in range(100):
        test = {"state" : bool(i %2== 0)}
        try:
            await client.send(test)
            print(f"   Sent #{i+1}/100")
        except Exception as e:
            print(f"   Send failed: {e}")
        await asyncio.sleep(2)

    await asyncio.sleep(30)
    await client.disconnect()
    print("🏁 Test completed.")


if __name__ == "__main__":
    asyncio.run(main())

Configuration Files

Place these two files in the same folder as your script (or pass base_path):

  • serviceDef.json
  • serviceToken.json

Official Website

For full documentation, API reference, and more examples visit: https://nikki.build

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

nikki_python-2.0.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

nikki_python-2.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file nikki_python-2.0.1.tar.gz.

File metadata

  • Download URL: nikki_python-2.0.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for nikki_python-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3ac622a1edb19f028ae32563dc259cc2214431a1678fd022b316c536619d9ab4
MD5 c7f25713167e49744e7a46d877197d6c
BLAKE2b-256 cc93d34e3c0335700bb5d02ad6deeb16d0286eaef4fcc4a80a4efb77a753a9ac

See more details on using hashes here.

File details

Details for the file nikki_python-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: nikki_python-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for nikki_python-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e146798bccc84a34112a449413808fabaab5f08f51fd7946e1bdee6446f03aca
MD5 5b4d40c40c008590cabcbf7cd8d56b7b
BLAKE2b-256 ac685d8ac2df474a7b976bf461d7d9724514b37223d7a66961cc6ae8fb5265b6

See more details on using hashes here.

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