Update User Location

Send GPS location for threat distance calculations

POST /api/v1/cannonball/location/

Updates the user's GPS location for distance-based threat calculations. Location is stored in cache for real-time threat filtering.

Request Body

{
  "lat": 34.0522,
  "lon": -118.2437,
  "heading": 180,
  "speed": 65
}

Request Fields

FieldTypeRequiredDescription
latfloatYesLatitude (-90 to 90)
lonfloatYesLongitude (-180 to 180)
headingfloatNoDevice heading in degrees (0-360)
speedfloatNoDevice speed in mph

Response

{
  "status": "ok",
  "location": {
    "lat": 34.0522,
    "lon": -118.2437
  }
}

Behavior

Authenticated Users

  • Location is stored persistently and associated with user account
  • Updates trigger Celery task for background processing
  • Enables personalized threat tracking across sessions

Anonymous Users

  • Location is stored in cache with session key
  • Cache TTL: 300 seconds (5 minutes)
  • Limited tracking functionality

Example Request

curl -X POST "https://api.skyspy.io/api/v1/cannonball/location/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "lat": 34.0522,
    "lon": -118.2437,
    "heading": 180
  }'

Response Codes

CodeDescription
200Location updated successfully
400Invalid coordinates or request body
401Unauthorized - Invalid or missing authentication

Usage Notes

  • Update location frequently (every 5-30 seconds) for accurate distance calculations
  • Include heading for relative bearing calculations in threat responses
  • For mobile apps, use high-accuracy GPS mode for best results