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)
def onData(data):
print("📨", data)
# Example reply
# client.send_nowait({"state": True})
client.onData = onData
await client.connect()
await client.send({
"state": True
})
await asyncio.sleep(30)
await client.disconnect()
if __name__ == "__main__":
asyncio.run(main())
Event Callbacks
client.onConnect
client.onDisconnect
client.onError
client.onData
Example
def onData(data):
print(data)
client.onData = onData
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
👉 https://github.com/nikki-build/nikki.python
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.1.tar.gz.
File metadata
- Download URL: nikki_python-2.2.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f5ba4ff64088883788b86e4f21622735df00cbc510a561f795d35f8f7f9a3cc
|
|
| MD5 |
0f467a8503bfc7a1c67d7137db4f5761
|
|
| BLAKE2b-256 |
9c95fa6b929e44c64c24d2b77695fd3bc18309aacce9370fde2cd750ac6e9ce6
|
File details
Details for the file nikki_python-2.2.1-py3-none-any.whl.
File metadata
- Download URL: nikki_python-2.2.1-py3-none-any.whl
- Upload date:
- Size: 10.1 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 |
1fdf96f7a28b4fba4d96cc730387e3be5b3844d7bbfbbdf3b4114c0955f8c675
|
|
| MD5 |
18f1d57339159543cf77ac73e1531810
|
|
| BLAKE2b-256 |
d0d790ae84107a3e14f51c567648e5a67f3683051d26e2667e07a8ad0c86a7f2
|