import Runloop from '@runloop/api-client';
const client = new Runloop({
bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
});
const devboxResourceUsageView = await client.devboxes.retrieveResourceUsage('id');
console.log(devboxResourceUsageView.id);import os
from runloop_api_client import Runloop
client = Runloop(
bearer_token=os.environ.get("RUNLOOP_API_KEY"), # This is the default and can be omitted
)
devbox_resource_usage_view = client.devboxes.retrieve_resource_usage(
"id",
)
print(devbox_resource_usage_view.id)curl --request GET \
--url https://api.runloop.ai/v1/devboxes/{id}/usage \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runloop.ai/v1/devboxes/{id}/usage",
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: Bearer <token>"
],
]);
$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.runloop.ai/v1/devboxes/{id}/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.runloop.ai/v1/devboxes/{id}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runloop.ai/v1/devboxes/{id}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"total_active_seconds": 123,
"total_elapsed_seconds": 123,
"vcpu_seconds": 123,
"memory_gb_seconds": 123,
"disk_gb_seconds": 123,
"start_time_ms": 123,
"status": "<string>",
"end_time_ms": 123
}Get resource usage for a Devbox.
Get resource usage metrics for a specific Devbox. Returns CPU, memory, and disk consumption calculated from the Devbox’s lifecycle, excluding any suspended periods for CPU and memory. Disk usage includes the full elapsed time since storage is consumed even when suspended.
import Runloop from '@runloop/api-client';
const client = new Runloop({
bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
});
const devboxResourceUsageView = await client.devboxes.retrieveResourceUsage('id');
console.log(devboxResourceUsageView.id);import os
from runloop_api_client import Runloop
client = Runloop(
bearer_token=os.environ.get("RUNLOOP_API_KEY"), # This is the default and can be omitted
)
devbox_resource_usage_view = client.devboxes.retrieve_resource_usage(
"id",
)
print(devbox_resource_usage_view.id)curl --request GET \
--url https://api.runloop.ai/v1/devboxes/{id}/usage \
--header 'Authorization: Bearer <token>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runloop.ai/v1/devboxes/{id}/usage",
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: Bearer <token>"
],
]);
$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.runloop.ai/v1/devboxes/{id}/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.runloop.ai/v1/devboxes/{id}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runloop.ai/v1/devboxes/{id}/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"total_active_seconds": 123,
"total_elapsed_seconds": 123,
"vcpu_seconds": 123,
"memory_gb_seconds": 123,
"disk_gb_seconds": 123,
"start_time_ms": 123,
"status": "<string>",
"end_time_ms": 123
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The Devbox ID.
Response
OK
The devbox ID.
Total time in seconds the devbox was actively running (excludes time spent suspended).
Total elapsed time in seconds from devbox creation to now (or end time if terminated). Includes all time regardless of devbox state.
vCPU usage in vCPU-seconds (total_active_seconds multiplied by the number of vCPUs).
Memory usage in GB-seconds (total_active_seconds multiplied by memory in GB).
Disk usage in GB-seconds (total_elapsed_seconds multiplied by disk size in GB). Disk is billed for elapsed time since storage is consumed even when suspended.
The devbox creation time in milliseconds since epoch.
The current status of the devbox.
The devbox end time in milliseconds since epoch, or null if still running.
Was this page helpful?
