Chart
GETChart
The chart endpoint returns the main time-series data for a website dashboard. Use it to build visitor charts, revenue charts, or custom-event goal charts outside TrackFox.
How It Works
The endpoint authenticates each request using your website's API token, which you can generate here. It then resolves the requested period and returns visitor data merged with the website's configured goal data.
Use Case
Use this endpoint when you need to render your own analytics chart in an internal dashboard, client portal, or reporting workflow.
Endpoint
GET https://trackfox.app/api/v1/chart
Authentication
This endpoint requires authentication using a Bearer token.
Authorization: Bearer tf_your_api_token_here
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| websiteId | string | Yes | The unique identifier of your website |
| period | string | No | Time period to query. Defaults to last30d. Supported values: today, yesterday, last24h, last7d, last30d, wtd, mtd, ytd, all, custom |
| startDate | string | Only for period=custom |
Custom period start date. Any valid date string accepted by JavaScript Date |
| endDate | string | Only for period=custom |
Custom period end date. Any valid date string accepted by JavaScript Date |
| timezone | string | No | Timezone used for period calculations. Defaults to UTC |
Response Format
On success, the API returns a JSON object with period metadata, the active goal type, and chart points.
{
"period": {
"label": "last30d",
"startDate": "2026-04-15T00:00:00.000Z",
"endDate": "2026-05-14T23:59:59.999Z",
"timezone": "UTC",
"interval": "day"
},
"goalType": "revenue",
"data": [
{
"time": "Apr 15",
"visitors": 42,
"revenue": 12900,
"transactions": 3,
"customEventCount": null,
"customEventSessions": null,
"_dateKey": "2026-04-15"
}
]
}
Response Fields
- period: The resolved date range, timezone, and chart interval.
- goalType: The website goal mode. Usually
revenueorcustom_event. - data: Ordered chart points for the selected period.
- visitors: Unique visitors for the chart point.
- revenue and transactions: Present when the goal type is
revenue; otherwisenull. - customEventCount and customEventSessions: Present when the goal type is
custom_event; otherwisenull. - _dateKey and _monthKey: Internal grouping keys that may be present depending on the selected interval.
Error Responses
400 Bad Request
The request is missing websiteId, uses an invalid period, or uses period=custom without valid startDate and endDate values.
401 Unauthorized
The Authorization header is missing, malformed, or contains an invalid API token.
404 Not Found
No website exists for the supplied websiteId.
500 Internal Server Error
An unexpected server error occurred.
Example Usage
cURL Request
curl "https://trackfox.app/api/v1/chart?websiteId=your_website_id&period=last30d" \
-H "Authorization: Bearer tf_your_api_token_here"
JavaScript Fetch
const response = await fetch(
"https://trackfox.app/api/v1/chart?websiteId=your_website_id&period=last30d",
{
headers: {
Authorization: "Bearer tf_your_api_token_here",
},
},
);
const data = await response.json();
console.log(data.data);
Next Steps
Need help? Contact us for assistance.
Suggest features? We'd love your feedback