Waveforms & Schematics
Generate Waveform SVG (JSON-Wrapped)
Section titled “Generate Waveform SVG (JSON-Wrapped)”POST /api/waveforms/svgRenders waveform data as an SVG plot, returned inside a JSON wrapper.
Request body:
{ "waveform": { "...WaveformData from simulation response..." }, "title": "Output Voltage", "width": 800, "height": 500, "signals": ["v(2)"]}| Field | Type | Default | Description |
|---|---|---|---|
waveform | WaveformData | (required) | Simulation result data |
title | string | "" | Plot title |
width | integer | 800 | SVG width in pixels |
height | integer | 500 | SVG height in pixels |
signals | string[] | all | Signals to include in the plot |
Response 200:
{ "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" ...>...</svg>"}Generate Waveform SVG (Raw)
Section titled “Generate Waveform SVG (Raw)”POST /api/waveforms/svg/rawSame request body as above, but returns the raw SVG string with Content-Type: image/svg+xml. Useful for piping directly to a file:
curl -X POST https://spicebook.warehack.ing/api/waveforms/svg/raw \ -H "Content-Type: application/json" \ -d '{ "waveform": { ...waveform data... }, "title": "DC Sweep", "signals": ["v(2)"] }' \ -o plot.svgGenerate Schematic
Section titled “Generate Schematic”POST /api/notebooks/{notebook_id}/cells/{cell_id}/schematicNo request body. The cell must be type spice. Parses the cell’s netlist and renders a circuit diagram.
Response 200:
{ "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" ...>...</svg>", "success": true, "error": null, "component_map": { "R1": "resistor", "V1": "voltage_source", "C1": "capacitor" }}| Field | Type | Description |
|---|---|---|
svg | string | SVG markup of the circuit diagram |
success | boolean | Whether generation succeeded |
error | string | null | Error message if generation failed |
component_map | object | Component reference → type mapping |
The SVG includes standard IEEE symbols for components. Resistors with parseable values (0.01Ω–1GΩ) render with color-coded bands on the zigzag symbol.
End-to-End Example
Section titled “End-to-End Example”Simulate a circuit and generate both a waveform plot and schematic:
# 1. Create a notebook with a SPICE cell and run itRESPONSE=$(curl -s -X POST https://spicebook.warehack.ing/api/notebooks/compose \ -H "Content-Type: application/json" \ -d '{ "title": "RC Filter", "cells": [ {"type": "spice", "source": "V1 in 0 AC 1\nR1 in out 1k\nC1 out 0 1u\n.ac dec 100 1 1meg\n.end"} ], "run": true }')
# 2. Extract IDsNB_ID=$(echo $RESPONSE | jq -r '.id')CELL_ID=$(echo $RESPONSE | jq -r '.cells[0].id')
# 3. Generate schematiccurl -s -X POST "https://spicebook.warehack.ing/api/notebooks/$NB_ID/cells/$CELL_ID/schematic" \ | jq -r '.svg' > schematic.svg
# 4. Generate waveform plot from simulation resultsWAVEFORM=$(echo $RESPONSE | jq '.cells[0].outputs[0].data.waveform')curl -s -X POST https://spicebook.warehack.ing/api/waveforms/svg/raw \ -H "Content-Type: application/json" \ -d "{\"waveform\": $WAVEFORM, \"title\": \"Bode Plot\"}" \ -o bode.svg