Visitor Counter API Documentation
Our API allows you to track visitors to your website and retrieve visitor statistics at no cost. No API keys, no rate limits, no premium features - just a simple, free API.
Introduction
The Visitor Counter API allows you to track visitors to your website and retrieve visitor statistics completely free of charge.
Base URL
https://visitor.6developer.com
Authentication - No API Key Required
No authentication is required for basic usage. Your domain is used as an identifier. Our API has no usage limits.
API Endpoints
Record a Visit
Records a visit to your website.
Request Body
{ "domain": "example.com", "timezone": "America/New_York", // Optional, defaults to UTC "page_path": "/blog/my-article", // Optional, the path of the current page "page_title": "My Article Title", // Optional, the title of the current page "referrer": "https://google.com", // Optional, the referrer URL "search_query": "my search query" // Optional, the search query if coming from a search engine }
Response
{ "dashboardUrl": "https://visitor.6developer.com/dashboard?domain=example.com", "totalCount": 42, "todayCount": 5 }
Example
fetch('https://visitor.6developer.com/visit', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain: 'example.com', timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, page_path: window.location.pathname, page_title: document.title, referrer: document.referrer }) }) .then(response => response.json()) .then(data => console.log(data));
Get Visit Statistics
Retrieves visitor statistics for your website.
Query Parameters
domain: "example.com" // Required
Response
{ "dashboardUrl": "https://visitor.6developer.com/dashboard?domain=example.com", "totalCount": 42, "todayCount": 5 }
Example
fetch('https://visitor.6developer.com/visit?domain=example.com') .then(response => response.json()) .then(data => console.log(data));
Integration
To integrate the Visitor Counter with your website, add the following script to your HTML:
<script> (function() { const domain = encodeURIComponent(window.location.hostname); const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; const page_path = window.location.pathname; const page_title = document.title; const referrer = document.referrer; // Extract search query if coming from a search engine let search_query = ''; if (referrer) { try { const url = new URL(referrer); if (url.hostname.includes('google.com')) { search_query = url.searchParams.get('q') || ''; } else if (url.hostname.includes('bing.com')) { search_query = url.searchParams.get('q') || ''; } else if (url.hostname.includes('yahoo.com')) { search_query = url.searchParams.get('p') || ''; } else if (url.hostname.includes('duckduckgo.com')) { search_query = url.searchParams.get('q') || ''; } } catch (e) { // Invalid URL, ignore } } fetch('https://visitor.6developer.com/visit', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain, timezone, page_path, page_title, referrer, search_query }) }) .then(response => response.json()) .then(data => { console.log('Visitor count:', data); // You can display the count on your page if (document.getElementById('visitor-count')) { document.getElementById('visitor-count').textContent = data.totalCount; } }) .catch(error => console.error('Error:', error)); })(); </script>
For more detailed installation instructions, see our Installation Guide.
NPM Package
We also offer an NPM package for easier integration:
npm install @rundevelrun/free-visitor-counter
For more information about our NPM package, visit our GitHub repository.
Error Handling
The API returns standard HTTP status codes:
- 200 OK - The request was successful.
- 400 Bad Request - The request was invalid.
- 404 Not Found - The requested resource was not found.
- 500 Internal Server Error - An error occurred on the server.
Error Response Format
{ "error": "Error message description" }
Rate Limiting - Generous Limits
The API is rate limited to 100 requests per minute per IP address, which is more than enough for most websites.
If you exceed this limit, you will receive a 429 Too Many Requests response.
CORS Policy
Our API allows cross-origin requests from any domain.
Ready to Get Started?
Start tracking your website visitors today.