REST API

LogHub provides a simple and powerful REST API to allow you to log events, actions, and performance data from any application or service. With just a few HTTP requests, you can send logs, record time measurements, and integrate LogHub into your workflows. Below are the main API endpoints and example requests to help you get started.

Authorization

LogHub’s REST API uses Bearer Token Authentication to securely authenticate requests. Every request you make to the API must include an Authorization header containing your unique API key as a Bearer token. You can obtain your API key by creating a project in LogHub.

API Endpoints

Add a new Log

Endpoint: POST https://api.loghub.cloud/log

Use this endpoint to send new log entries to LogHub. You can specify details such as the function, message, log type, and other attributes.

curl --request POST \
--url https://api.loghub.cloud/log \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'User-Agent: cURL-Client/1.0.0' \
--data '{
"function": "Test Function",
"message": "Test message",
"type": 0
}'

Request Body Parameters

  • function: (String) The name of the function or process generating the log.
  • message: (String/JSON/Object) The content of the log message.
  • type: (Integer) The type of log. E.g., 1 for INFO, 2 for SUCCESS, etc.

This endpoint allows you to send logs in real-time, giving you visibility into the operations and events happening in your system.

Add a New Timer

Endpoint: POST https://api.loghub.cloud/timer

Use this endpoint to record the duration of a process or function by sending the timer name and duration.

curl --request POST \
--url https://api.loghub.cloud/timer \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'User-Agent: cURL-Client/1.0.0' \
--data '{
"timer": "timer-name",
"duration": "3.55"
}'

Request Body Parameters

  • timer: (String) The name of the timer or process being measured.
  • duration: (String) The amount of time the process took, typically in seconds.

By using this endpoint, you can track the performance of your application’s key functions and log the duration of critical operations.

With the LogHub REST API, you can seamlessly integrate logging and performance tracking into any project, regardless of the language or framework you’re using. Simply use the provided endpoints to send logs and time measurements, and start monitoring your system in real-time.