API Overview
Programmatically access your Ghost Metrics analytics data.
Introduction
The Ghost Metrics API allows you to programmatically request analytics reports, manage websites, users, goals, and more. You can retrieve data in multiple formats (JSON, XML, CSV) and integrate Ghost Metrics data into your own applications, dashboards, or automated workflows.
What You Can Do
Reporting API
Retrieve analytics data programmatically:
- Visitor data — Visits, unique visitors, returning visitors
- Behavior data — Page views, downloads, outlinks, site search
- Acquisition data — Referrers, search engines, campaigns
- Goal data — Conversions, revenue, goal completions
- Real-time data — Current visitors, live actions
Management API
Manage your Ghost Metrics configuration:
- Websites — List and manage tracked websites
- Goals — Create, update, and delete goals
- Segments — Manage saved segments
- Users — User management (admin only)
- Scheduled Reports — Configure automated reports
API Endpoint
All API requests are made to your Ghost Metrics instance:
https://[your-subdomain].ghostmetrics.cloud/For example:
https://example.ghostmetrics.cloud/?module=API&method=VisitsSummary.get&idSite=1&period=day&date=today&format=JSON&token_auth=YOUR_TOKENResponse Formats
The API supports multiple output formats:
| Format | Parameter | Description |
|---|---|---|
| JSON | format=JSON | JavaScript Object Notation (recommended) |
| XML | format=xml | Extensible Markup Language |
| CSV | format=csv | Comma-separated values |
| TSV | format=tsv | Tab-separated values (Excel-friendly) |
| HTML | format=html | Simple HTML table |
| RSS | format=rss | RSS feed (for date ranges) |
JSON Example Response
{
"nb_uniq_visitors": 1250,
"nb_visits": 1543,
"nb_actions": 4521,
"bounce_rate": "45%",
"avg_time_on_site": 185
}Quick Start
Here’s a simple example to get yesterday’s visit summary:
https://example.ghostmetrics.cloud/?module=API
&method=VisitsSummary.get
&idSite=1
&period=day
&date=yesterday
&format=JSON
&token_auth=YOUR_TOKEN_HEREParameters explained:
module=API— Required for all API callsmethod=VisitsSummary.get— The API method to callidSite=1— Your website IDperiod=day— Time period (day, week, month, year, range)date=yesterday— The date to queryformat=JSON— Response formattoken_auth— Your authentication token
Finding Your API Credentials
Website ID (idSite)
- Log into Ghost Metrics
- Go to Administration → Websites → Manage
- Find your website in the list
- The ID is shown in the first column
Authentication Token
- Log into Ghost Metrics
- Go to Administration → Personal → Security
- Under Auth tokens, create a new token
- Copy and securely store the token
See Authentication for detailed instructions.
API Modules
The API is organized into modules, each handling different functionality:
Core Analytics Modules
| Module | Description |
|---|---|
VisitsSummary | Overall visit metrics |
Actions | Page views, downloads, outlinks |
Referrers | Traffic sources, keywords, campaigns |
UserCountry | Geographic data |
DevicesDetection | Device, browser, OS data |
VisitTime | Time-based analytics |
VisitorInterest | Engagement metrics |
Premium Feature Modules
| Module | Description |
|---|---|
Goals | Goal conversions and revenue |
Funnels | Funnel analytics |
FormAnalytics | Form interaction data |
HeatmapSessionRecording | Heatmaps and recordings |
MediaAnalytics | Video and audio analytics |
AbTesting | A/B test results |
Management Modules
| Module | Description |
|---|---|
SitesManager | Website management |
UsersManager | User management |
SegmentEditor | Segment management |
ScheduledReports | Report scheduling |
Annotations | Date annotations |
Rate Limits
API requests are subject to rate limiting to ensure service stability. If you need higher limits for your use case, contact support.
Security Best Practices
- Never expose your token in client-side code or public repositories
- Use HTTPS for all API requests
- Create dedicated tokens for different applications
- Use POST requests for tokens when possible
- Rotate tokens periodically
Next Steps
- Authentication — Set up API access
- Making Requests — Learn request structure
- Parameters Reference — All available parameters
- Common Methods — Most-used API methods
- Code Examples — Working code samples