Skip to main content

Get Current Project Usage by Date

Use this endpoint to retrieve the daily usage (in bytes) for a specific TURN Server project during the current billing cycle. You can authenticate by providing either the secretKey (for your entire application) or the projectApiKey (for a specific project).


GET
https://<appname>.metered.live/api/v2/turn/project/:projectId/current_usage_by_date

<appname> - Replace with the name of your app.
:projectId - The unique ID of the project whose daily usage you want to retrieve.


Request​

GET /api/v2/turn/project/:projectId/current_usage_by_date

Path Parameter​

ParameterDescriptionData Type
projectIdThe unique ID of the project (must be a valid ObjectId)String

Query Parameters (Authentication)​

ParameterDescriptionData Type
secretKeyYour application's secret key, found in Dashboard → Developers → Secret Key. Only one of secretKey or projectApiKey is required.String
projectApiKeyThe API key for the specific project. Only one of secretKey or projectApiKey is required.String

Responses​

Success Response​

Returns an array of objects representing usage per date within the current billing cycle:

FieldDescriptionData Type
dateThe calendar date in YYYY-MM-DD formatString
usageInBytesTotal bytes consumed on that dateNumber

HTTP Status: 200 OK

Example Success Response​
[
{
"date": "2025-01-20",
"usageInBytes": 123456
},
{
"date": "2025-01-21",
"usageInBytes": 987654
}
]

Error Responses​

HTTP StatusMessageDescription
400Project not foundThe specified project does not exist or does not match the provided secretKey or projectApiKey.

Code Examples​

cURL​

curl -X GET "https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/current_usage_by_date?secretKey=<YOUR_SECRET_KEY>"

JavaScript (Fetch)​

fetch(`https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/current_usage_by_date?projectApiKey=<PROJECT_API_KEY>`)
.then(response => response.json())
.then(data => {
console.log("Daily Usage Data:", data);
// Each element in data has { date: 'YYYY-MM-DD', usageInBytes: number }
})
.catch(error => console.error("Error:", error));