Wiki de Militant API

Inicio rapido

Paginas auxiliares, ejemplos y detalles tecnicos en una maquetacion mas limpia.

1. Instalar la API

mkdir -p militant-api-install
cd militant-api-install
curl -fsSLO https://gitlab.com/militant1/api-installer/-/raw/main/militant-api
chmod +x militant-api
./militant-api

2. Verificar que la API responde

curl http://localhost:9082/v1/index.php

3. Crear un token

curl -X POST http://localhost:9082/v1/auth.php \
  -H "Content-Type: application/json" \
  -d '{"username":"tu_usuario","password":"tu_password"}'

4. Usar un endpoint

curl http://localhost:9082/v1/posts.php \
  -H "Authorization: Bearer TU_TOKEN"

LiveKit (opcional)

Configura LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET (entorno o config/livekit.local.php via /admin/livekit.php). Probar un token:

curl -X POST "http://localhost:9082/v1/lives.php?path=token" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer TU_TOKEN" \
  -d '{"roomName":"test","identity":"user-1","name":"Test","canPublish":false}'

La interfaz /admin/livekit.php (secretos LiveKit) es solo para técnicos: misma regla que Militant (users.is_admin = 1, pestaña Técnicos en admin.php).

TURN / WebRTC (opcional pero recomendado en 4G/5G)

Configura WEBRTC_TURN_URLS, WEBRTC_TURN_AUTH_SECRET, WEBRTC_TURN_TTL, WEBRTC_TURN_REALM (entorno o config/turn.local.php via /admin/turn.php).

/v1/settings.php devuelve entonces stun_servers, turn_servers y webrtc_ice_servers. Si WEBRTC_TURN_AUTH_SECRET esta presente, la API genera credenciales TURN temporales HMAC compatibles con coturn use-auth-secret.

5. Actualizar

./militant-api update

6. Desinstalar

./militant-api uninstall

Mas detalles: README.md y DOCKER.md