Skip to main content

Python SDK for Nikki Services, PlayStore and Agent APIs.

Project description

Nikki Python SDK

A simple Python SDK for building Nikki Services, communicating over WebSockets, interacting with the PlayStore, and executing Agent workflows.

Features

  • 🚀 Simple async WebSocket client
  • 🔄 Automatic reconnect (optional)
  • 📄 Automatic loading of serviceDef.json and serviceToken.json
  • ✅ Strict configuration validation
  • 📨 Event-based callbacks
  • ⚡ Async and non-blocking message sending
  • 🛡️ Built-in rate limiting and payload protection
  • 🤖 Agent API support
    • Execute plans
    • Get current execution plan
  • 📦 PlayStore API support
    • Store JSON data
    • Upload files
    • Retrieve stored data

Installation

pip install nikki_python

Project Structure

Place these configuration files in your project directory:

project/
│
├── serviceDef.json
├── serviceToken.json
└── app.py

Or specify a custom location using:

client = nikkiServiceBase(base_path="path/to/config")

Quick Start

import asyncio
from nikki_python.nikki_client import nikkiServiceBase

async def main():
    client = nikkiServiceBase(auto_reconnect=True)

    client.onConnect = lambda _: print("✅ Connected")
    client.onDisconnect = lambda d: print("❌ Disconnected", d)
    client.onError = lambda e: print("⚠️ Error", e)

    # Core data callback
    def onData(data):
        print("📨 Data received:", data)

    # Service response callback
    def onResponseData(data):
        print("📥 Received response:", data)

    # Agent realtime update callbacks
    def onAgentDataEventUpdate(data):
        print("🤖 Agent data event:", data)

    def onAgentPlanUpdate(data):
        print("📋 Agent plan event:", data)

    # Assign callbacks
    client.onData = onData
    client.onResponseData = onResponseData
    client.onAgentDataEventUpdate = onAgentDataEventUpdate
    client.onAgentPlanUpdate = onAgentPlanUpdate

    await client.connect()

    await client.send({
        "state": True
    })

    await asyncio.sleep(30)
    await client.disconnect()

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

Event Callbacks

# General & Connection
client.onConnect
client.onDisconnect
client.onError
client.onData

# Service Response
client.onResponseData

# Agent Realtime Updates
client.onAgentDataEventUpdate
client.onAgentPlanUpdate

Example Usage

def onResponseData(data):
    print("Received response", data)

def onAgentDataEventUpdate(data):
    print("Agent data event", data)

def onAgentPlanUpdate(data):
    print("Agent plan event", data)

client.onResponseData = onResponseData
client.onAgentDataEventUpdate = onAgentDataEventUpdate
client.onAgentPlanUpdate = onAgentPlanUpdate

Sending Data

Async

await client.send({
    "state": True
})

Fire-and-forget

Safe to call from callbacks.

client.send_nowait({
    "state": True
})

Agent API

The SDK includes a wrapper around Nikki Agent APIs.

Get Current Plan

plan = client.getPlan()
print(plan)

Execute Actions

result = client.execute(
    actions=[
        {
            "type": "speak",
            "text": "Hello!"
        }
    ],
    desc="Greeting user"
)
print(result)

PlayStore API

Store JSON

result = client.storeJson({
    "name": "Nikki",
    "version": "2.2.0"
})

Upload File

result = client.storeFile(
    "example.pdf"
)

Retrieve Store

store = client.getStore()
print(store)

Retrieve the complete store:

store = client.getStore(fullStore=True)

Configuration

The SDK automatically loads:

  • serviceDef.json
  • serviceToken.json

from the current working directory unless base_path is provided.

Requirements

  • Python 3.8+
  • serviceDef.json
  • serviceToken.json

Official Website

Documentation, Playground and API Reference:
👉 https://nikki.build

GitHub

👉 https://github.com

License

MIT License

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.2.2.tar.gz (10.8 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.2.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nikki_python-2.2.2.tar.gz
Algorithm Hash digest
SHA256 b02a44c1101625bc54672cef7f1cfc8c4b0df1439c13e302784e3da70de520b0
MD5 58e2c6e3cc5acf1d51df79f8e1fbf75e
BLAKE2b-256 7fd68876f4453e52e5f45b95cf8e2f352040b30cbe1a568a12f84712f8037ca9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nikki_python-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de5f776d818a2a3e4d9305fd9f0251f4c6625b04971a5683ea391407c460a03f
MD5 38398457d05030d41e547e999861c8e5
BLAKE2b-256 38529c65422ee28855a2760ea0efccb526814781e9077c9785992b539ac69481

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