Skip to main content
Real-time Logs
curl --request GET \
  --url https://api.squarecloud.app/v2/apps/{app_id}/realtime \
  --header 'Authorization: <authorization>'
import requests

url = "https://api.squarecloud.app/v2/apps/{app_id}/realtime"

headers = {"Authorization": "<authorization>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: '<authorization>'}};

fetch('https://api.squarecloud.app/v2/apps/{app_id}/realtime', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/realtime",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.squarecloud.app/v2/apps/{app_id}/realtime"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.squarecloud.app/v2/apps/{app_id}/realtime")
.header("Authorization", "<authorization>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.squarecloud.app/v2/apps/{app_id}/realtime")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'

response = http.request(request)
puts response.read_body
{
  "status": "<string>"
}
The API Playground is disabled for this endpoint due to the nature of SSE connections, which are not universally supported by browsers.
Authorization
string
required
The API key for your account. You can find this in your account settings.

Parameters

app_id
string
required
The ID of the application whose logs you want to monitor. This ID can be found in the URL of your application’s management panel.

Response

status
string
Indicates whether the call was successful.. success if successful, error if not.
In case of failure, the response will include a code field along with the error status, detailing the cause. If the request is successful, the response will be a text/event-stream stream containing the application’s realtime feed. Each connection lasts up to 10 minutes. Each account may hold 5 concurrent realtime connections (REALTIME_MAX_CONNECTIONS) and each application 30 across all users (REALTIME_MAX_CONNECTIONS_APP); exceeding either returns 429.

Server-Sent Events (SSE) Structure

The response is a continuous stream in text/event-stream format. Each message is composed of an event field and a data field. Shapes vary by event, so parse payloads defensively.

Event Types

  • system: Protocol-level signals. The data line is a single uppercase code: REALTIME_CONNECTING | <sseId> on connect, then any of REALTIME_TIMEOUT, REALTIME_DISCONNECTED, REALTIME_RECONNECT, or REALTIME_ERROR.
  • logs: A single log line whose first character is a stream-id byte: \x01 (stdout) or \x02 (stderr). Read data.charCodeAt(0) (1 = stdout, 2 = stderr), then data.slice(1) for the text. A line without that prefix byte is stdout.
  • status: Live container metrics as a JSON string, about one frame per second. The first frame of each (re)connection is complete: { cpu, cpuLimit, ram: [usedMB, limitMB], status, netIO: { i, o, new: { i, o } }, bIO: { i, o }, uptime } (uptime is the start time as epoch ms; netIO.new is bytes per second). Every later frame is lean, carrying only { cpu, ram, netIO, bIO } — merge each onto the last complete frame, keeping the previous cpuLimit, status, and uptime. While this stream is open, prefer it over polling GET /v2/apps/{app_id}/status, which can be up to about a minute stale for an app with an open realtime stream.
  • error: Carries an error code such as CONTAINER_NOT_FOUND.
In the example below, \x01 / \x02 stand for the raw stdout / stderr prefix bytes.
event: system
data: REALTIME_CONNECTING | abc123-1716000000000-deadbeef

event: status
data: {"cpu":12.5,"cpuLimit":100,"ram":[128,512],"status":"running","netIO":{"i":2048,"o":4096,"new":{"i":64,"o":128}},"bIO":{"i":0,"o":0},"uptime":1716000000000}

event: status
data: {"cpu":13.1,"ram":[131,512],"netIO":{"i":2176,"o":4288,"new":{"i":72,"o":140}},"bIO":{"i":0,"o":0}}

event: logs
data: \x01Server listening on :3000

event: logs
data: \x02Error: connect ECONNREFUSED