API Reference
Referencia de la API HTTP de Dantse.
Base URL
https://api.dantse.cc
Autenticacion
La mayoria de endpoints requieren un token JWT en el header:
Authorization: Bearer <token>
Endpoints publicos
Health check
GET /health
Response: { "ok": true }
Login
POST /auth/login
Content-Type: application/json
{
"username": "user",
"password": "pass"
}
Response:
{
"token": "eyJ...",
"user": {
"id": "abc123",
"username": "user",
"isAdmin": false
}
}
Endpoints protegidos
Files
# Listar archivos
GET /files/list?path=/
# Leer archivo
GET /files/read?path=/archivo.txt
# Escribir archivo
POST /files/write
{ "path": "/archivo.txt", "content": "..." }
# Borrar
DELETE /files/delete?path=/archivo.txt
# Crear carpeta
POST /files/mkdir
{ "path": "/nueva-carpeta" }
Expose
# Exponer puerto
POST /expose
{ "port": 3000, "subdomain": "mi-app" }
# Listar expuestos
GET /expose
# Quitar
DELETE /expose/:subdomain
Publish
# Publicar
POST /publish
{
"path": "/docs",
"slug": "mi-docs", // opcional
"ttl": "24h", // opcional
"password": "secret", // opcional
"maxAccess": 10 // opcional
}
# Listar publicados
GET /publish
# Despublicar
DELETE /publish/:id
Sessions
# Ver sesiones activas
GET /sessions
# Cerrar sesion
DELETE /sessions/:id
WebSocket
wss://api.dantse.cc/ws?token=<jwt>
Recibe eventos de cambios en el filesystem:
{
"type": "fs",
"event": "change", // add, change, unlink
"path": "/archivo.txt"
}
Errores
Todos los errores siguen este formato:
{
"error": "Mensaje de error"
}
| Status | Significado |
|---|---|
| 400 | Bad Request - Datos invalidos |
| 401 | Unauthorized - Token invalido o expirado |
| 403 | Forbidden - Sin permisos |
| 404 | Not Found - Recurso no existe |
| 500 | Internal Error - Error del servidor |