/v1/usage - Compresto Documentation
Get usage statistics
cURL
curl --request GET \
--url https://api.compresto.app/v1/usage \
--header 'X-API-Key: <api-key>'
Python
import requests
url = "https://api.compresto.app/v1/usage"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.compresto.app/v1/usage', 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.compresto.app/v1/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 => [\
"X-API-Key: <api-key>"\
],\
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.compresto.app/v1/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Unirest (Java)
HttpResponse<String> response = Unirest.get("https://api.compresto.app/v1/usage")
.header("X-API-Key", "<api-key>")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.compresto.app/v1/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body
Response Codes
- 200
- 401
Sample Response (200)
{
"plan": "free",
"usage": {
"current": 123,
"limit": 123,
"resetAt": "2023-11-07T05:31:56Z"
},
"totals": {
"bytesIn": 123,
"bytesOut": 123,
"savedBytes": 123,
"savedPercent": 123
}
}
Error Response (401)
{
"error": "<string>",
"message": "<string>"
}
Authorizations
- X-API-Key: string, header, required
API key for authentication. Get your key at https://compresto.app/dashboard.
Response Structure
plan: enum
, required
Current subscription tier (options:free,pro,business).usage: object, required
Showchild attributes.totals: object, required
Showchild attributes.