GPS Tracker Server
Server is running and operational
Available API Endpoints:
All Devices: /api/devices
Get list of all registered GPS devices with their current status
Specific Device: /api/device/{imei}
Get detailed information about a specific device by IMEI
Example: /api/device/0869066063180153
Device Location History: /api/device/{imei}/locations
ENHANCED
Get location history for a device with advanced filtering options
Query Parameters:
?filter=today - Get today's locations
?filter=yesterday - Get yesterday's locations
?filter=week - Get last 7 days
?filter=month - Get last 30 days
?date=2024-07-30 - Get locations for specific date
?start_date=2024-07-30&end_date=2024-07-31 - Date range
Device History (alias): /api/device/{imei}/history
ENHANCED
Same as locations endpoint with identical filtering capabilities
Examples:
/api/device/0869066063180153/history?filter=today
/api/device/0869066063180153/history?filter=week
/api/device/0869066063180153/history?date=2024-07-30
Device Alerts: /api/device/{imei}/alerts
Get all SOS alerts and emergency notifications for a specific device
Example: /api/device/0869066063180153/alerts
All Alerts: /api/alerts
Get all SOS alerts from all devices across the system
Date Filtering Features:
Predefined Filters:
Quick access to common time periods
filter=today - Current day (00:00 to 23:59)
filter=yesterday - Previous day
filter=week - Last 7 days from now
filter=month - Last 30 days from now
Custom Date Ranges:
Flexible date range selection
Single Date: date=YYYY-MM-DD
Date Range: start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
Supported Formats: YYYY-MM-DD, DD-MM-YYYY, MM/DD/YYYY
Response Format:
Data Sorting:
All location data is automatically sorted by timestamp (newest first)
Performance: Optimized MongoDB queries with proper indexing
Format: JSON response with CORS headers enabled
Server Configuration:
- GPS Socket Port: 5005 (TCP)
- HTTP API Port: 8000
- Database: MongoDB (3 collections: devices, locations, alerts)
- Device Timeout: 5 minutes (devices marked offline after inactivity)
- Supported Protocols: LOGIN (0x01), GPS (0x12, 0x22, 0x19, 0xA0), HEARTBEAT (0x13), SOS (0x26, 0x94)
- Date Filtering: Advanced query parameter support for efficient data retrieval
Features:
- Real-time GPS device tracking
- Device login/registration
- Location history storage with date filtering
- SOS alert handling
- Device online/offline status
- Automatic device cleanup
- RESTful API with JSON responses
- CORS enabled for web applications
- Advanced query parameters for efficient data filtering
- Optimized MongoDB queries with sorting
API Usage Examples:
Recent Activity:
GET /api/device/0869066063180153/locations?filter=today
GET /api/device/0869066063180153/locations?filter=week
Historical Data:
GET /api/device/0869066063180153/locations?date=2024-07-30
GET /api/device/0869066063180153/history?start_date=2024-07-30&end_date=2024-07-31
Performance Benefits:
- Reduced Data Transfer: Filter data at the database level
- Faster Response Times: Return only requested date ranges
- Lower Memory Usage: Avoid loading unnecessary historical data
- Better User Experience: Quick access to recent vs historical data
- Scalable Architecture: Efficient queries even with large datasets