'use client'; import { Button } from '@/components/ui/Button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card'; import { Select } from '@/components/ui/Input'; import { useToast } from '@/components/ui/Toast'; import { useEffect, useState } from 'react'; export default function SdkGuidePage() { const { success } = useToast(); const [clients, setClients] = useState([]); const [selectedClientId, setSelectedClientId] = useState(''); useEffect(() => { async function loadClients() { try { const res = await fetch('/api/clients'); if (res.ok) { const data = await res.json(); const list = data.clients || []; setClients(list); if (list.length > 0) { setSelectedClientId(list[0].clientId); } } } catch { // ignore } } loadClients(); }, []); const activeClient = clients.find((c) => c.clientId === selectedClientId) || clients[0]; const sampleToken = activeClient?.token || 'YOUR_SIGNED_CLIENT_JWT_TOKEN'; const pythonSnippet = `from datastack_sdk import DataStackClient # Initialize client using credentials generated in /vcon/clients client = DataStackClient( server_url="http://localhost:4000", token="${sampleToken}" ) # Connect with automatic reconnection backoff if client.connect(): # 1. Sync single event in realtime res = client.sync({ "event_type": "page_view", "url": "/products/wireless-headphones", "user_id": "usr_9942", "referrer": "google.com" }) print("Sync response:", res) # 2. Sync high-throughput batch of records batch_res = client.batch_sync([ {"sensor": "temp", "value": 24.5, "unit": "C"}, {"sensor": "humidity", "value": 61.2, "unit": "%"}, {"sensor": "pressure", "value": 1013.25, "unit": "hPa"} ]) print("Batch response:", batch_res) client.disconnect() `; const copySnippet = (text: string, label: string) => { navigator.clipboard.writeText(text); success('Copied', `${label} copied to clipboard`); }; return (
{/* Header */}

Python SDK

{/* Installation Step */}
pip install ./sdk-python
{/* Interactive Code Generator */}
Client Code Example {clients.length > 0 && (
)}
              {pythonSnippet}
            
); }