Realtime API
How It Works
The realtime API endpoint calculates the current number of visitors by counting unique visitors who have triggered pageview events in the last 3 minutes. This matches the polling interval used by the HeaderList component in the dashboard.
The endpoint authenticates each request using your website's API token, which you can generate here. Each website has its own unique API token for security.
Use Case
Your pricing card can have a discounted price for the next (for example, 15) customers. You can show the current visitors on that component to display urgency to the user to convert.
Endpoint
GET https://versatailor.com/api/v1/realtime
Authentication
This endpoint requires authentication using a Bearer token.
Authorization: Bearer vt_your_api_token_here
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
websiteId | string | Yes | The unique identifier of your website |
Response Format
On success, the API returns a JSON object with the following structure:
{
"currentVisitors": number,
"websiteId": string,
"timestamp": string (ISO 8601 format)
}
Response Fields
- currentVisitors: The number of currently active visitors on your website
- websiteId: The ID of the website the data pertains to
- timestamp: The time when the data was collected (in ISO 8601 format)
Error Responses
The API may return the following error responses:
401 Unauthorized
Missing or invalid authorization header. Expected: Bearer <token>
401 Unauthorized
Invalid token format
400 Bad Request
websiteId is required
404 Not Found
Website not found
401 Unauthorized
No API token configured for this website
401 Unauthorized
Invalid API token
500 Internal Server Error
Internal server error
Example Usage
cURL Request
curl "https://versatailor.com/api/v1/realtime?websiteId=your_website_id" \
-H "Authorization: Bearer vt_your_api_token_here"
JavaScript Fetch
fetch('https://versatailor.com/api/v1/realtime?websiteId=your_website_id', {
headers: {
"Authorization": "Bearer vt_your_api_token_here"
}
})
.then(response => response.json())
.then(data => console.log(data));
Successful Response
{
"currentVisitors": 5,
"websiteId": "your_website_id",
"timestamp": "2025-07-30T17:09:37.000Z"
}
Need help? Contact us for assistance.
Suggest features? We'd love your feedback