-
Notifications
You must be signed in to change notification settings - Fork 0
Trip Update API
The Trip Update API allows you to post location updates, battery status, and messages during a trip. These updates track your journey in real-time.
Base URL: http://localhost:8081/api/1/trips
Authentication: Required (USER or ADMIN role)
Post a location update for a trip.
Endpoint: POST /api/1/trips/{tripId}/updates
| Parameter | Type | Description |
|---|---|---|
| tripId | UUID | Trip's unique identifier |
{
"location": {
"latitude": 42.8805,
"longitude": -8.5457,
"altitude": 365.2
},
"battery": 85,
"message": "Just arrived in Santiago! What an amazing journey! π"
}| Field | Type | Required | Description |
|---|---|---|---|
| location | GeoLocation | Yes | Current location coordinates |
| location.latitude | number | Yes | Latitude (-90 to 90) |
| location.longitude | number | Yes | Longitude (-180 to 180) |
| location.altitude | number | No | Altitude in meters |
| battery | integer | No | Battery level (0-100) |
| message | string | No | Status message or update text |
Status: 201 Created
{
"id": "770e8400-e29b-41d4-a716-446655440000",
"tripId": "660e8400-e29b-41d4-a716-446655440000",
"location": {
"latitude": 42.8805,
"longitude": -8.5457,
"altitude": 365.2
},
"battery": 85,
"message": "Just arrived in Santiago! What an amazing journey! π",
"reactions": {
"heart": 0,
"smiley": 0,
"sad": 0,
"laugh": 0,
"anger": 0
},
"timestamp": "2025-10-16T15:30:00Z"
}| Field | Type | Description |
|---|---|---|
| id | UUID | Update's unique identifier |
| tripId | UUID | Associated trip ID |
| location | GeoLocation | Location coordinates |
| battery | integer | Battery level |
| message | string | Status message |
| reactions | ReactionsDTO | Reaction counts |
| timestamp | ISO 8601 | When the update was created |
curl -X POST http://localhost:8081/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{
"location": {
"latitude": 42.8805,
"longitude": -8.5457,
"altitude": 365.2
},
"battery": 85,
"message": "Made it to Santiago!"
}'Post just your current location without additional information:
curl -X POST http://localhost:8081/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{
"location": {
"latitude": 42.8805,
"longitude": -8.5457
}
}'Share a status message with your location:
curl -X POST http://localhost:8081/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{
"location": {
"latitude": 43.0000,
"longitude": -8.2000
},
"message": "Taking a rest at this beautiful viewpoint! ποΈ",
"battery": 65
}'Include location, battery, altitude, and message:
curl -X POST http://localhost:8081/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{
"location": {
"latitude": 42.9500,
"longitude": -8.3000,
"altitude": 450.5
},
"battery": 72,
"message": "Climbing up the mountain pass. Great views!"
}'The Trip Update API is designed to work seamlessly with OwnTracks, a popular location tracking app:
- Configure OwnTracks to use HTTP mode
- Set the endpoint URL to:
http://your-server:8081/api/1/trips/{tripId}/updates - Add authentication header:
Authorization: Bearer <your-token>
OwnTracks sends location data that maps to the Trip Update format:
-
latβlocation.latitude -
lonβlocation.longitude -
altβlocation.altitude -
battβbattery
Trip doesn't exist:
{
"timestamp": "2025-10-16T10:30:00.000Z",
"status": 404,
"error": "Not Found",
"message": "Trip not found",
"path": "/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates"
}Invalid location data:
{
"timestamp": "2025-10-16T10:30:00.000Z",
"status": 400,
"error": "Bad Request",
"message": "Latitude must be between -90 and 90",
"path": "/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates"
}Cannot update someone else's trip:
{
"timestamp": "2025-10-16T10:30:00.000Z",
"status": 403,
"error": "Forbidden",
"message": "You don't have permission to update this trip",
"path": "/api/1/trips/660e8400-e29b-41d4-a716-446655440000/updates"
}- Walking/Hiking: Every 5-10 minutes
- Driving: Every 1-2 minutes
- Stationary: Only when location changes significantly
- Reduce update frequency when battery is low
- Use coarse location accuracy for longer battery life
- Consider disabling updates below certain battery threshold
- Keep messages concise (under 280 characters recommended)
- Use emojis to convey emotion and save characters
- Include relevant context (weather, terrain, mood)
When internet connectivity is unavailable:
- Queue updates locally on the device
- Retry with exponential backoff
- Send queued updates when connection is restored
The following endpoints for querying trip updates are planned:
-
GET /api/1/trips/{tripId}/updates- Get all updates for a trip -
GET /api/1/trips/{tripId}/updates/latest- Get the most recent update -
GET /api/1/trips/{tripId}/updates/{updateId}- Get a specific update
- Trip API - Create and manage trips
- Comment API - Comment on trip updates
- Getting Started Guide - Full workflow examples
Welcome to the Trip Tracker Backend API documentation! This wiki provides comprehensive information about all available REST APIs in the system.
- API Overview - Introduction to the API architecture and general concepts
- Getting Started - Quick start guide with examples
- Authentication - How to authenticate and obtain JWT tokens
- User API - User management endpoints
- Trip API - Trip creation, updates, and queries
- Trip Plan API - Trip planning and route management
- Comment API - Comments and reactions on trips
- Trip Update API - Location updates and tracking
- API Response Formats - Common response structures and error handling
- Security & Authorization - Authentication, roles, and permissions
The Trip Tracker Backend follows a CQRS (Command Query Responsibility Segregation) architecture with three main services:
| Service | Port | Purpose | Base Path |
|---|---|---|---|
| tracker-auth | 8083 | Authentication & user registration | /api/1/auth |
| tracker-command | 8081 | Write operations (Create, Update, Delete) | /api/1 |
| tracker-query | 8082 | Read operations (Queries) | /api/1 |
All API endpoints (except registration and login) require JWT authentication. Include the token in the Authorization header:
Authorization: Bearer <your-jwt-token>
Get your token by calling the Login endpoint.
Here's a quick example to get you started:
# 1. Register a new user
curl -X POST http://localhost:8083/api/1/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"john","password":"secret123"}'
# 2. Use the returned token to create a trip
curl -X POST http://localhost:8081/api/1/trips \
-H "Authorization: Bearer <your-token>" \
-H "Content-Type: application/json" \
-d '{"name":"My Camino","visibility":"PUBLIC"}'
# 3. Query your trips
curl -X GET http://localhost:8082/api/1/trips/me \
-H "Authorization: Bearer <your-token>"For interactive API documentation with try-it-out functionality, access the Swagger UI:
- Auth Service: http://localhost:8083/swagger-ui.html
- Command Service: http://localhost:8081/swagger-ui.html
- Query Service: http://localhost:8082/swagger-ui.html
For issues, questions, or contributions:
- GitHub Issues: Report a bug or request a feature
- Source Code: View on GitHub
Ready to get started? Check out the Getting Started Guide!