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.jsonandserviceToken.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.jsonserviceToken.json
from the current working directory unless base_path is provided.
Requirements
- Python 3.8+
serviceDef.jsonserviceToken.json
Official Website
Documentation, Playground and API Reference:
👉 https://nikki.build
GitHub
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 nikki_python-2.2.3.tar.gz.
File metadata
- Download URL: nikki_python-2.2.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75c531070c0cacfdd27cf29808960c8498bcea993eeec52aa99857687046a11f
|
|
| MD5 |
a465a98deeaea94e35a687f17f85b1f7
|
|
| BLAKE2b-256 |
d15d6d031819abb60cc538e5384941ed80aaa3524415bf178edfdae17e677e0a
|
File details
Details for the file nikki_python-2.2.3-py3-none-any.whl.
File metadata
- Download URL: nikki_python-2.2.3-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b52d15e184d007d55b4eeb0a2cfdc9c56ae5725e6dd77224afb936d94d54e95
|
|
| MD5 |
9ee174498b1b472f21204e7440b1e099
|
|
| BLAKE2b-256 |
981d9fb592eb8ac72f27c307b8d4f6a53680f2d2726a9236fa1897362f5f0556
|