Documentation

API Reference

POST /v1/generate

Generate a new logging token.

curl -X POST https://logapi.org/v1/generate

Response:

{
  "token": "abc123...",
  "created_at": "2025-01-06T12:00:00.000Z"
}

POST /v1/{token}

Send log data. Accepts JSON body or query parameters.

JSON Body:

curl -X POST https://logapi.org/v1/YOUR_TOKEN \
  -H "Content-Type: application/json" \
  -d '{"event": "user_login", "user_id": 123, "ip": "192.168.1.1"}'

Query Parameters:

curl -X POST "https://logapi.org/v1/YOUR_TOKEN?event=user_login&user_id=123"

Response:

{
  "success": true,
  "timestamp": "2025-01-06T12:00:00.000Z"
}

GET /v1/{token}

Retrieve all logs for a token (newest first, max 1000).

curl https://logapi.org/v1/YOUR_TOKEN

Response:

[
  {
    "timestamp": "2025-01-06T12:00:00.000Z",
    "data": {
      "event": "user_login",
      "user_id": 123
    }
  }
]

DELETE /v1/{token}

Clear all logs for a token (token remains active).

curl -X DELETE https://logapi.org/v1/YOUR_TOKEN

Response:

{
  "success": true,
  "deleted_count": 42
}

Examples

Quick curl examples

POST a URL-encoded log (common for forms and simple scripts):

curl -X POST -d "log_type=warning&log_message=Temperature%20over%20threshold&temp=82" https://logapi.org/v1/YOUR_TOKEN

POST JSON (structured payload):

curl -X POST -H "Content-Type: application/json" -d '{"log_type":"info","msg":"service started","uptime":120}' https://logapi.org/v1/YOUR_TOKEN

Retrieve logs (GET returns JSON):

curl -X GET https://logapi.org/v1/YOUR_TOKEN

Windows PowerShell

Use Invoke-RestMethod to send JSON from PowerShell:

$body = @{log_type='warning'; log_message='Temperature over threshold'; temp=82} | ConvertTo-Json
Invoke-RestMethod -Uri 'https://logapi.org/v1/YOUR_TOKEN' -Method Post -Body $body -ContentType 'application/json'

Simple GET in PowerShell:

Invoke-RestMethod -Uri 'https://logapi.org/v1/YOUR_TOKEN' -Method Get

Node.js (server or script)

import fetch from 'node-fetch';

// Send JSON
await fetch('https://logapi.org/v1/YOUR_TOKEN', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ log_type: 'info', msg: 'job completed' })
});

// Retrieve logs
const res = await fetch('https://logapi.org/v1/YOUR_TOKEN');
const logs = await res.json();
console.log(logs);

Python (requests)

import requests

# Send JSON
resp = requests.post(
    'https://logapi.org/v1/YOUR_TOKEN',
    json={ 'log_type': 'warning', 'log_message': 'Temperature over threshold', 'temp': 82 }
)
print(resp.json())

# Retrieve logs
resp = requests.get('https://logapi.org/v1/YOUR_TOKEN')
logs = resp.json()
print(f"Retrieved {len(logs)} logs")

Raspberry Pi / Linux

On small Linux boards you can use curl or Python; example using curl in a cron job or shell script:

# from the shell
curl -X POST -d "log_type=info&log_message=booted&host=$(hostname)" https://logapi.org/v1/YOUR_TOKEN

Or use the Python example above for richer logic and retries.

ESP8266 / ESP32 (Arduino)

Use the built-in HTTP client to POST JSON from microcontrollers:

// Arduino (ESP8266/ESP32) pseudo-example
#include <WiFi.h>
#include <HTTPClient.h>

HTTPClient http;
http.begin("https://logapi.org/v1/YOUR_TOKEN");
http.addHeader("Content-Type", "application/json");
int code = http.POST("{\"log_type\":\"sensor\",\"value\":42}");
String resp = http.getString();
http.end();

Power BI / Excel (Power Query)

Import logs as JSON and visualize them. In Power BI Desktop use Get Data → Web and enter the GET URL:

https://your-server.example.com/v1/YOUR_TOKEN

Alternatively use Power Query M to fetch and parse JSON:

let
  Source = Json.Document(Web.Contents("https://logapi.org/v1/YOUR_TOKEN"))
in
  Source

Use the returned JSON table to build visuals or export to Excel.

Integrating from applications

Any language or platform that can make HTTP requests can send logs to LogAPI. Use POST for sending data and GET for retrieving logs. Keep tokens secret — anyone with the token can read and delete logs.

FAQ

Do tokens expire?

No, tokens are permanent and never expire.

What happens when I exceed 1MB storage?

The oldest logs are automatically deleted (FIFO) to keep total storage under 1MB per token.

What are the rate limits?

60 requests per minute per token, and 60 requests per minute per IP address.

What's the maximum request size?

4KB (4096 bytes) per request.

Can I recover deleted logs?

No, when you clear logs or when automatic FIFO deletion occurs, the data is permanently removed.