WellNuo/API_DOCUMENTATION.md
Sergei 4a5331b2e4 [TEST] Initial setup - NOT PRODUCTION CODE
⚠️ This is test/experimental code for API integration testing.
Do not use in production.

Includes:
- WellNuo API integration (dashboard, patient context)
- Playwright tests for API verification
- WebView component for dashboard embedding
- API documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-11 13:25:14 -08:00

11 KiB
Raw Blame History

WellNuo API Documentation

Overview

WellNuo - система мониторинга здоровья пожилых людей. API позволяет получать данные о пациентах, их активности, локации и состоянии здоровья.

Дата тестирования: 2025-12-10 Статус: Работает


Endpoints

Base URL

https://eluxnetworks.net/function/well-api/api

Web Dashboard

https://react.eluxnetworks.net/dashboard

Authentication

Credentials

Username: anandk
Password: anandk_8
Client ID: 001

Получение токена

Request:

curl -X POST "https://eluxnetworks.net/function/well-api/api" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "function=credentials&clientId=001&user_name=anandk&ps=anandk_8&nonce=$(uuidgen)"

Parameters:

Parameter Type Required Description
function string Yes credentials
clientId string Yes 001
user_name string Yes Username
ps string Yes Password
nonce string Yes Unique UUID for each request

Response (200 OK):

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "privileges": "21,38,29,41,42",
  "user_id": 43,
  "max_role": 2,
  "status": "200 OK"
}

Token Format: JWT (JSON Web Token)

  • Algorithm: HS256
  • Expiration: ~7 days (exp claim in payload)

API Endpoints

1. Dashboard List (Список пациентов)

Request:

curl -X POST "https://eluxnetworks.net/function/well-api/api" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "function=dashboard_list&user_name=anandk&token=<JWT_TOKEN>&date=2025-12-10&nonce=<UUID>"

Parameters:

Parameter Type Required Description
function string Yes dashboard_list
user_name string Yes Username
token string Yes JWT access token
date string Yes Date in YYYY-MM-DD format
nonce string Yes Unique UUID

Response:

{
  "result_list": [
    {
      "user_id": 25,
      "name": "Ferdinand Zmrzli",
      "address": "661 Encore Way",
      "time_zone": "America/Los_Angeles",
      "picture": "/",
      "bathroom_at": "2025-12-10T13:52:00",
      "kitchen_at": "2025-12-10T14:48:00",
      "bedroom_at": "2025-12-10T09:14:00",
      "temperature": 72.77,
      "smell": "clean",
      "bathroom_delayed": [6, 12],
      "kitchen_delayed": [6, 12],
      "bedroom_delayed": [13, 16],
      "last_location": "Kitchen",
      "last_detected_time": "2025-12-10T14:47:00",
      "before_last_location": "Living Room",
      "last_present_duration": 1,
      "wellness_score_percent": 90,
      "wellness_descriptor": "Great!",
      "wellness_descriptor_color": "bg-green-100 text-green-700",
      "bedroom_temperature": 15.22,
      "sleep_bathroom_visit_count": 0,
      "bedroom_co2": 500,
      "shower_detected_time": "2025-12-10T13:52:00",
      "breakfast_detected_time": 0,
      "living_room_time_spent": 0,
      "outside_hours": 0,
      "most_time_spent_in": "Bedroom",
      "sleep_hours": 11.12,
      "units": "°F",
      "deployment_id": 21,
      "location_list": ["Living Room", "Bathroom Small", "Bedroom", "Dining Room", "Bathroom Main", "Kitchen", "Office"]
    }
  ],
  "status": "200 OK"
}

Available Patients (Тестовые данные)

User ID Name Address Timezone Deployment ID
25 Ferdinand Zmrzli 661 Encore Way America/Los_Angeles 21
34 Helga Kleine - Europe/Berlin 29
48 Đurđica Božičević-Radić A.T. Mimare 38 Europe/Zagreb 38
50 Tarik Hubana - Europe/Sarajevo 41
54 Jamie Rivera-Vallestero 2088 Trafalgar Ave US/Pacific 42

Data Structure

Patient Object Fields

Field Type Description
user_id int Unique patient ID
name string Patient full name
address string Home address
time_zone string IANA timezone
temperature float Current room temperature
smell string Air quality (clean/etc)
last_location string Current room
last_detected_time datetime Last activity timestamp
wellness_score_percent int Health score 0-100
wellness_descriptor string Status text
sleep_hours float Hours slept
bathroom_at datetime Last bathroom visit
kitchen_at datetime Last kitchen visit
bedroom_at datetime Last bedroom visit
location_list array Available rooms in home
units string Temperature units (°F/°C)
deployment_id int Sensor deployment ID

Integration Notes

WebView Integration (React Native)

Для встраивания dashboard в React Native приложение:

import { WebView } from 'react-native-webview';

// Inject credentials and auto-login
const injectedJS = `
  localStorage.setItem('auth2', JSON.stringify({
    username: 'anandk',
    token: '${token}',
    user_id: 43
  }));
  window.location.reload();
  true;
`;

<WebView
  source={{ uri: 'https://react.eluxnetworks.net/dashboard' }}
  injectedJavaScript={injectedJS}
  javaScriptEnabled={true}
  domStorageEnabled={true}
/>

Request Headers

All requests use:

Content-Type: application/x-www-form-urlencoded

Nonce Generation

Each request requires a unique nonce (UUID):

const nonce = crypto.randomUUID();
// or
const nonce = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
  const r = Math.random() * 16 | 0;
  return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});

Error Handling

Status Description
200 OK Success
401 Invalid token
403 Access denied
404 Resource not found
405 Method not allowed (use POST)

Quick Test Commands

1. Get Token

curl -s -X POST "https://eluxnetworks.net/function/well-api/api" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "function=credentials&clientId=001&user_name=anandk&ps=anandk_8&nonce=test-123"

2. Get Dashboard

TOKEN="<paste_token_here>"
curl -s -X POST "https://eluxnetworks.net/function/well-api/api" \
  -d "function=dashboard_list&user_name=anandk&token=$TOKEN&date=$(date +%Y-%m-%d)&nonce=test-456"


Patient Context API (для AI чата)

Endpoint

https://wellnuo.smartlaunchhub.com/api/patient/context

Request

curl -s "https://wellnuo.smartlaunchhub.com/api/patient/context"

Response Structure

API возвращает детальные данные о пациенте для использования в AI чате:

{
  "patient": {
    "id": "dad",
    "name": "John Smith",
    "age": 78,
    "relationship": "Father",
    "address": "123 Oak Street, San Francisco, CA",
    "timezone": "America/Los_Angeles",
    "emergency_contact": { "name": "Sarah Smith", "phone": "+1 (555) 123-4567" }
  },
  "current_status": {
    "location": "Living Room",
    "presence_detected": true,
    "is_moving": false,
    "last_movement": "2025-12-10T22:51:43.316Z",
    "estimated_activity": "resting",
    "time_in_current_room_minutes": 45
  },
  "environment": {
    "living_room": {
      "temperature_c": 22.2, "temperature_f": 72,
      "humidity_percent": 45, "co2_ppm": 650,
      "voc_index": 85, "light_lux": 320,
      "air_quality_status": "good",
      "presence": true, "motion_level": "low"
    }
  },
  "sleep_analysis": {
    "last_night": {
      "bed_time_detected": "2025-11-30T22:18:00Z",
      "wake_time_detected": "2025-12-01T05:45:00Z",
      "total_hours": 7.45,
      "quality_score": 78,
      "bathroom_visits": 1
    }
  },
  "activity_patterns": {
    "today": {
      "total_active_minutes": 185,
      "sedentary_minutes": 240,
      "rooms_visited": ["Bedroom", "Bathroom", "Kitchen", "Living Room"]
    }
  },
  "recent_events": [
    {
      "time": "2025-12-01T10:45:00Z",
      "type": "presence",
      "event": "Continued presence in living room",
      "room": "Living Room"
    }
  ],
  "alerts": {
    "active": [],
    "recent": [
      {
        "id": "alert_001",
        "type": "possible_fall",
        "severity": "high",
        "timestamp": "2025-11-15T14:22:00Z",
        "room": "Bathroom",
        "resolved": true
      }
    ]
  }
}

Доступные данные для чата:

Раздел Описание
patient Информация о пациенте
current_status Текущее местоположение и активность
environment Данные сенсоров по комнатам
environment_history История показателей за день
sleep_analysis Анализ сна
activity_patterns Паттерны активности
recent_events Последние события (до 90 записей)
alerts Активные и недавние алерты

Files

  • tests/api-check.spec.js - Playwright tests for API
  • tests/network-capture.spec.js - Network capture for debugging
  • tests/api-discovery.spec.js - API endpoint discovery
  • tests/screenshots/ - Visual verification screenshots


React Native WebView Integration

Installation

npm install react-native-webview

Usage Example

import { DashboardWebView } from './src/components';

function DashboardScreen() {
  const handlePatientSelect = (patientId: number, patientName: string) => {
    console.log('Selected patient:', patientId, patientName);
    // Navigate to patient details or start voice chat
  };

  return (
    <DashboardWebView
      onPatientSelect={handlePatientSelect}
      onError={(error) => console.error(error)}
    />
  );
}

Component: src/components/DashboardWebView.tsx

Компонент автоматически:

  1. Получает JWT токен через API
  2. Автоматически логинится в веб-интерфейс
  3. Отображает dashboard внутри приложения
  4. Перехватывает клики на пациентах

Credentials в коде:

const CREDENTIALS = {
  username: 'anandk',
  password: 'anandk_8',
  clientId: '001'
};


Gitea Repository Access

Credentials

URL: https://gitea.wellnua.com
Username: sergei_t
Password: WellNuo2025!Secure
Email: serter2069@gmail.com

Repository

https://gitea.wellnua.com/robert/MobileApp_react_native

Clone Command

git clone https://sergei_t:WellNuo2025%21Secure@gitea.wellnua.com/robert/MobileApp_react_native.git

Local Clone

~/Desktop/Wellnuo/wellnuo-mobile-repo/

Contact / Support