This document describes the available API endpoints for managing voxels in the system.
All API endpoints are relative to: /api/voxel
Add or remove voxels. Supports both single voxel operations and batch operations.
{
"x": 0,
"y": 0,
"z": 0,
"action": "add" // or "remove"
}
[
{
"x": 0,
"y": 0,
"z": 0,
"action": "add"
},
{
"x": 1,
"y": 0,
"z": 0,
"action": "add"
},
{
"x": 0,
"y": 1,
"z": 0,
"action": "remove"
}
]
x
(number, required): X coordinate (0-99)y
(number, required): Y coordinate (0-99)z
(number, required): Z coordinate (0-24)action
(string, required): Either "add" or "remove"
{
"success": true,
"activeVoxels": ["0,0,0", "1,0,0"] // Array of active voxel coordinates
}
{
"error": "Error message here",
"status": 400 // or other appropriate status code
}
Retrieve all active voxels.
{
"activeVoxels": ["0,0,0", "1,0,0", "0,1,0"] // Array of active voxel coordinates
}
Remove all voxels from the system.
{
"success": true,
"activeVoxels": [] // Empty array as all voxels are removed
}
400
: Invalid input (coordinates out of range or invalid action)500
: Internal server error
- X range: 0-99
- Y range: 0-99
- Z range: 0-24
fetch('/api/voxel', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
x: 0,
y: 0,
z: 0,
action: 'add'
})
});
fetch('/api/voxel', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify([
{ x: 0, y: 0, z: 0, action: 'add' },
{ x: 1, y: 0, z: 0, action: 'add' },
{ x: 0, y: 1, z: 0, action: 'add' }
])
});
fetch('/api/voxel')
.then(res => res.json())
.then(data => console.log(data.activeVoxels));
fetch('/api/voxel', {
method: 'DELETE'
});