Skip to content

API Overview

Loggator provides a comprehensive REST API for programmatic access to logs, containers, and AI chat functionality.

http://localhost:3000/api

For production, replace with your deployment URL.

Currently, Loggator does not require authentication for API access. If you need authentication:

  1. Use a reverse proxy (nginx, Traefik)
  2. Implement API keys at the proxy level
  3. Or fork the project and add custom auth
EndpointMethodDescription
/api/statusGETService health check
/api/versionGETLoggator version info
EndpointMethodDescription
/api/containersGETList all monitored containers
/api/containers/[id]GETGet specific container info
EndpointMethodDescription
/api/logs/searchGETSearch logs with filters
/api/logs/containersGETList containers with log counts
/api/logs/histogramGETGet log histogram data
EndpointMethodDescription
/api/chatPOSTChat with AI assistant

All API responses follow this structure:

{
"success": true,
"data": { ... }
}
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE"
}
CodeMeaningDescription
200OKRequest succeeded
400Bad RequestInvalid parameters
404Not FoundResource not found
500Internal Server ErrorServer error
503Service UnavailableService not ready

Currently, Loggator does not implement rate limiting. Consider:

  • Using a reverse proxy for rate limiting
  • Implementing caching for frequent queries
  • Being respectful of server resources

Loggator allows CORS from all origins by default. To restrict:

  1. Use a reverse proxy
  2. Configure CORS headers at proxy level
  3. Or modify the SvelteKit configuration

Endpoints that return lists support pagination:

  • limit - Number of results (default: 50, max: 100)
  • offset - Skip N results (default: 0)
Terminal window
curl "http://localhost:3000/api/logs/search?query=error&limit=20&offset=40"

Many endpoints support filtering:

  • fromTimestamp - Unix timestamp (milliseconds)
  • toTimestamp - Unix timestamp (milliseconds)
  • container - Container name or ID
  • containerId - Exact container ID
  • stream - stdout or stderr
Terminal window
curl "http://localhost:3000/api/logs/search?query=error&limit=10"
Terminal window
curl "http://localhost:3000/api/containers"
Terminal window
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Show me errors"}
]
}'

Currently, no official SDKs exist. Use any HTTP client:

const response = await fetch(
"http://localhost:3000/api/logs/search?query=error",
);
const data = await response.json();
import requests
response = requests.get('http://localhost:3000/api/logs/search',
params={'query': 'error'})
data = response.json()
resp, err := http.Get("http://localhost:3000/api/logs/search?query=error")
Terminal window
curl "http://localhost:3000/api/logs/search?query=error"

Loggator does not currently support webhooks. For notifications:

  1. Poll the API periodically
  2. Use external monitoring tools
  3. Or implement custom webhooks via fork

Current API version: v1 (implicit, no version in URL)

Future versions will use URL versioning:

  • /api/v1/... - Version 1
  • /api/v2/... - Version 2
{
"success": false,
"error": "Invalid query parameter",
"code": "INVALID_PARAMETER"
}

Solution: Check parameter format and values

{
"success": false,
"error": "Container not found",
"code": "NOT_FOUND"
}

Solution: Verify resource exists

{
"success": false,
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}

Solution: Check Loggator logs, report bug if persistent

Implement client-side caching for:

  • Container lists (change infrequently)
  • Version info (static)
  • Historical logs (immutable)

For better performance:

  1. Use filters: Reduce result set size
  2. Limit results: Request only what you need
  3. Use time ranges: Narrow search scope
  4. Cache responses: Avoid redundant requests

For multiple queries, consider:

  • Combining filters in single request
  • Using AI chat to aggregate multiple queries
  • Implementing request queuing

In production:

https://your-domain.com/api/...

Use a reverse proxy (nginx, Traefik) for SSL termination.

Add auth at reverse proxy:

location /api/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://loggator:3000;
}

Always validate:

  • Query parameters
  • Request body
  • File uploads (if any)

Protect against abuse:

limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
location /api/ {
limit_req zone=api burst=20;
proxy_pass http://loggator:3000;
}

Log API requests:

  • Track usage patterns
  • Detect anomalies
  • Identify abuse

See individual endpoint pages for detailed examples.

Create a Postman collection:

{
"info": {
"name": "Loggator API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Search Logs",
"request": {
"method": "GET",
"url": "{{baseUrl}}/api/logs/search?query=error"
}
}
],
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:3000"
}
]
}