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
Parameter | Description | Data Type |
---|---|---|
projectId | The unique ID of the project (must be a valid ObjectId) | String |
Query Parameters (Authentication)
Parameter | Description | Data Type |
---|---|---|
secretKey | Your application's secret key, found in Dashboard → Developers → Secret Key. Only one of secretKey or projectApiKey is required. | String |
projectApiKey | The 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:
Field | Description | Data Type |
---|---|---|
date | The calendar date in YYYY-MM-DD format | String |
usageInBytes | Total bytes consumed on that date | Number |
HTTP Status: 200 OK
Example Success Response
[
{
"date": "2025-01-20",
"usageInBytes": 123456
},
{
"date": "2025-01-21",
"usageInBytes": 987654
}
]
Error Responses
HTTP Status | Message | Description |
---|---|---|
400 | Project not found | The 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));