Documentation

ViTrack API

Access your GPS device data programmatically. List devices, read live telemetry, and query historical location, event, and alarm data.

https://your-domain.com/api/v1v1 · JSON

Authentication

All requests require an API key. Create one from Settings > API in your dashboard. Pass it via the x-api-key header or as a Bearer token.

bash
curl -H "x-api-key: vtk_live_your_key_here" \
  https://your-domain.com/api/v1/devices

Test keys

Prefixed vtk_test_ — use in development. Same data, same rate limits.

Production keys

Prefixed vtk_live_ — use in production integrations.

Permissions

Each API key has granular permissions set at creation. Requests to endpoints you don't have access to return 403.

PermissionGrants Access To
list_devicesGET /devices
read_currentGET /devices/current · GET /devices/:id/current
read_historyGET /devices/history · GET /devices/:id/history

Rate Limiting

60

requests / minute

10,000

requests / day

Exceeding limits returns 429 Too Many Requests. Limits are enforced per API key.

Endpoints

Error Codes

All errors return a JSON body with an error field and a timestamp.

CodeMeaning
400Invalid request parameters
401Missing or invalid API key
403Insufficient permissions or wrong org
404Device not found
429Rate limit exceeded
500Internal server error
json
{
  "error": "Invalid API key",
  "timestamp": "2026-05-06T16:02:14.988Z"
}

Code Examples

JavaScript / TypeScript

javascript
const API_KEY = process.env.VITRACK_API_KEY;
const BASE = 'https://your-domain.com/api/v1';

// List all devices
const res = await fetch(`${BASE}/devices`, {
  headers: { 'x-api-key': API_KEY }
});
const { data } = await res.json();

// Get current data for a specific device
const device = data.devices[0];
const current = await fetch(`${BASE}/devices/${device.id}/current`, {
  headers: { 'x-api-key': API_KEY }
}).then(r => r.json());

console.log(current.data.current_data.location);
// { latitude: 41.407, longitude: 2.137, timestamp: "..." }

// Get last 7 days of history
const weekAgo = new Date(Date.now() - 7 * 86400000).toISOString();
const history = await fetch(
  `${BASE}/devices/${device.id}/history?start_date=${weekAgo}&type=location`,
  { headers: { 'x-api-key': API_KEY } }
).then(r => r.json());

console.log(`${history.data.summary.total_locations} points, ${history.data.summary.distance_traveled} km`);

Python

python
import requests
import os

API_KEY = os.environ["VITRACK_API_KEY"]
BASE = "https://your-domain.com/api/v1"
headers = {"x-api-key": API_KEY}

# List all devices
devices = requests.get(f"{BASE}/devices", headers=headers).json()

for device in devices["data"]["devices"]:
    print(f"{device['name']}: {device['status']}, battery {device.get('battery_percentage', '?')}%")

# Get current telemetry for one device
device_id = devices["data"]["devices"][0]["id"]
current = requests.get(f"{BASE}/devices/{device_id}/current", headers=headers).json()

loc = current["data"]["current_data"]["location"]
print(f"Location: {loc['latitude']}, {loc['longitude']}")

# Get history with date range
history = requests.get(f"{BASE}/devices/{device_id}/history", headers=headers, params={
    "start_date": "2026-05-01T00:00:00Z",
    "end_date": "2026-05-06T23:59:59Z",
    "type": "location",
    "limit": 1000
}).json()

print(f"Distance: {history['data']['summary']['distance_traveled']} km")

cURL

bash
# List devices
curl -H "x-api-key: vtk_live_your_key" https://your-domain.com/api/v1/devices

# Current data for a device
curl -H "x-api-key: vtk_live_your_key" \
  https://your-domain.com/api/v1/devices/DEVICE_ID/current

# History with date range and type filter
curl -H "x-api-key: vtk_live_your_key" \
  "https://your-domain.com/api/v1/devices/DEVICE_ID/history?start_date=2026-05-01T00:00:00Z&type=location&limit=100"