struct LabelResponse: Decodable {
let place: String?
let label: String
let category: String?
let distanceMeters: Double?
let cached: Bool
enum CodingKeys: String, CodingKey {
case place, label, category, cached
case distanceMeters = "distance_meters"
}
}
var components = URLComponents(string: "https://api.geolabel.dev/label")!
components.queryItems = [
URLQueryItem(name: "lat", value: "35.4617"),
URLQueryItem(name: "lng", value: "-97.5149"),
]
var request = URLRequest(url: components.url!)
request.setValue("your_key_here", forHTTPHeaderField: "X-API-Key")
let (data, _) = try await URLSession.shared.data(for: request)
let result = try JSONDecoder().decode(LabelResponse.self, from: data)
print(result.category ?? "") // → "gym"
── Step 1 ──────────────────────────────────────
Action: Get Current Location
Output: Current Location (lat + lng)
── Step 2 ──────────────────────────────────────
Action: Get Contents of URL
URL: https://api.geolabel.dev/label
Method: GET
Headers: X-API-Key → your_key_here
Params: lat → Latitude (from step 1)
lng → Longitude (from step 1)
── Step 3 ──────────────────────────────────────
Action: Get Dictionary Value
Key: category
From: Contents of URL (step 2)
── Step 4 ──────────────────────────────────────
Action: If [Dictionary Value] equals "gym"
→ your actions here
End If
Rate limit headers
Every response includes these headers so you always know where you stand.