Chapter 5
RESTful APIs enable programmatic access to fusion data, AI predictions, and control optimization across all compliant systems.
The WIA-FUSION API provides a standardized interface for accessing fusion data, running AI predictions, and optimizing control parameters. The API uses REST principles with JSON payloads, JWT authentication, and WebSocket streaming for real-time data.
https://api.fusion.wia.live/v1https://api-staging.fusion.wia.live/v1
/plasma/state
Record a new plasma state measurement.
// Request
POST /api/v1/plasma/state
Content-Type: application/json
Authorization: Bearer <token>
{
"plasma_state": {
"shot_id": "KSTAR-20240415-001",
"timestamp": "2024-04-15T10:30:00Z",
"reactor": "KSTAR",
"core_parameters": {
"temperature_keV": { "ion": 10, "electron": 10 },
"density_m3": { "value": 1.0, "unit": "1e20/m3" }
}
}
}
// Response 201 Created
{
"success": true,
"shot_id": "KSTAR-20240415-001",
"recorded_at": "2024-04-15T10:30:00.150Z"
}
/plasma/state/{shot_id}
Retrieve plasma state for a specific shot.
/fusion/predict/disruption
Get AI-powered disruption prediction for current plasma state.
// Request
POST /api/v1/fusion/predict/disruption
{
"plasma_state": {
"temperature_keV": 10,
"density_m3": 1.0,
"plasma_current_ma": 15,
"beta_percent": 2.5
},
"diagnostics": {
"mhd_amplitude": 0.3,
"locked_mode_indicator": false
}
}
// Response
{
"prediction": {
"disruption_probability": 0.15,
"time_to_disruption_s": null,
"confidence": 0.92,
"risk_factors": [
{ "factor": "mhd_activity", "contribution": 0.08 },
{ "factor": "density_limit", "contribution": 0.05 }
],
"recommended_actions": [
{ "action": "monitor_mhd", "priority": "medium" }
]
}
}
/plasma/control/optimize
Request AI-optimized control parameters for target performance.
// Request
POST /api/v1/plasma/control/optimize
{
"current_state": {
"temperature_keV": 10,
"heating_power_mw": { "nbi": 30, "icrh": 10, "ecrh": 5 }
},
"target": {
"q_factor": 10,
"steady_state_duration_s": 300
},
"constraints": {
"max_heating_power_mw": 50,
"max_divertor_heat_mw_m2": 10
}
}
// Response
{
"optimized_control": {
"heating_power_mw": { "nbi": 33, "icrh": 10, "ecrh": 7 },
"predicted_performance": { "q_factor": 10.2 },
"confidence": 0.88
}
}
For real-time plasma monitoring, the API provides WebSocket streaming:
// Connect to WebSocket
const ws = new WebSocket('wss://api.fusion.wia.live/v1/stream/plasma?token=<jwt>');
// Subscribe to channels
ws.send(JSON.stringify({
action: 'subscribe',
channels: ['plasma_state', 'stability', 'control'],
reactor: 'KSTAR',
sample_rate_hz: 100
}));
// Receive data
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(`Q-factor: ${data.plasma_state.q_factor}`);
};
Official SDKs are available for TypeScript, Python, and other languages:
// TypeScript SDK
import { FusionClient } from '@wia/fusion-sdk';
const client = new FusionClient({
apiKey: process.env.WIA_FUSION_API_KEY,
reactor: 'KSTAR'
});
// Record plasma state
await client.plasma.recordState({
temperature_keV: { ion: 10, electron: 10 },
density_m3: 1.0
});
// Get disruption prediction
const prediction = await client.fusion.predictDisruption({
beta_percent: 2.5,
mhd_amplitude: 0.3
});
console.log(`Risk: ${prediction.probability * 100}%`);