vehk-axle
v2.0.0
Published
Official JavaScript/TypeScript SDK for Vehk Axle Fleet Management, GPS Tracking & Predictive Maintenance Platform
Maintainers
Readme
Vehk Axle JavaScript/TypeScript SDK
Official JavaScript/TypeScript SDK for the Vehk Axle Fleet Management, GPS Tracking & Predictive Maintenance Platform.
Installation
npm install vehk-axle
# or
yarn add vehk-axleWhat's New in v2.0.0
- GPS Tracking API - Send and retrieve real-time device location data
- Device Management API - List devices and get fleet-wide locations
- Scoped Permissions - Granular API key scopes (
telemetry:write,tracking:read, etc.) - Enforced Rate Limits - Per-key sliding window rate limiting (default 60 req/min)
- New Types -
TrackingDataandDeviceLocationTypeScript interfaces
Quick Start
import { VehkClient } from 'vehk-axle';
const client = new VehkClient('vehk_your_api_key');
// Send telemetry
await client.telemetry.send({
vehicle_id: 'VH-001',
sensor_data: { speed: 65, rpm: 2500, coolant_temp: 92 }
});
// Send GPS tracking data from a device
await client.tracking.send({
device_id: 'dev-abc123',
latitude: 12.9716,
longitude: 77.5946,
speed: 45.2,
ignition: true
});
// Get ML prediction
const prediction = await client.predictions.get('VH-001', {
speed: 65,
rpm: 2500
});
console.log(`Health Score: ${prediction.health_score}%`);Features
Telemetry
// Single telemetry
await client.telemetry.send({
vehicle_id: 'VH-001',
sensor_data: { speed: 65, rpm: 2500 },
timestamp: '2026-03-26T10:00:00Z',
location: { lat: 12.97, lng: 77.59 }
});
// Batch telemetry (up to 100)
const result = await client.telemetry.sendBatch([
{ vehicle_id: 'VH-001', sensor_data: { speed: 65 } },
{ vehicle_id: 'VH-002', sensor_data: { speed: 70 } },
]);
console.log(`Processed: ${result.records_processed}`);GPS Tracking (v2.0)
// Send tracking data from a configured device
await client.tracking.send({
device_id: 'dev-abc123',
latitude: 12.9716,
longitude: 77.5946,
speed: 45.2,
heading: 180,
ignition: true,
event: 'periodic'
});
// Batch tracking (up to 100)
await client.tracking.sendBatch([
{ device_id: 'dev-1', latitude: 12.97, longitude: 77.59, speed: 45 },
{ device_id: 'dev-2', latitude: 13.01, longitude: 77.61, speed: 30 },
]);
// Get all device locations (real-time fleet map)
const locations = await client.tracking.locations();
for (const loc of locations) {
console.log(`${loc.device_id}: ${loc.latitude}, ${loc.longitude}`);
}
// Get a single device location
const loc = await client.tracking.location('dev-abc123');
console.log(`Speed: ${loc.speed} km/h`);Device Management (v2.0)
// List all devices
const devices = await client.devices.list();
// Filter by status
const active = await client.devices.list('active');Predictions
const prediction = await client.predictions.get('VH-001', {
speed: 65, rpm: 2500, coolant_temp: 92
});
console.log(`Health: ${prediction.health_score}%`);
console.log(`Risk: ${prediction.risk_level}`);
// List recent predictions
const recent = await client.predictions.list('VH-001', 10);Vehicles
const vehicles = await client.vehicles.list();
for (const v of vehicles) {
console.log(`${v.vehicle_id}: ${v.health_score}%`);
}API Scopes (v2.0)
| Scope | Description |
|-------|-------------|
| telemetry:write | Send telemetry data |
| telemetry:read | Read telemetry history |
| tracking:write | Send GPS tracking data |
| tracking:read | Read device locations |
| devices:read | List devices |
| predict | Request ML predictions |
| vehicles:read | List vehicles |
Configuration
// Custom base URL (staging / private deployment)
const client = new VehkClient('vehk_your_key', 'https://api-staging.vehk.in');Error Handling
try {
const prediction = await client.predictions.get('VH-001', { speed: 65 });
} catch (err: any) {
// err.message includes status code: "[429] Rate limit exceeded"
console.error(err.message);
}TypeScript Types
All request/response types are exported:
import {
TelemetryData,
TrackingData,
DeviceLocation,
Prediction,
Vehicle,
BatchResult
} from 'vehk-axle';Requirements
- Node.js 14+ or modern browser environment
Getting Your API Key
- Log in to Vehk Dashboard
- Go to Settings > API Keys
- Click "Generate New Key"
- Copy the key (shown only once)
Support
License
MIT License - see LICENSE for details.
