The Locations API allows you to search for geographic locations used in the RC system. Locations are used to filter profiles and represent where Recursers are based.
use rc_api::{LocationSearchParams, ProfileSearchParams};// First, find the location IDlet locations = client.search_locations(LocationSearchParams { query: "Brooklyn".to_string(), limit: Some(1),})?;if let Some(brooklyn) = locations.first() { // Then search for profiles in that location let profiles = client.search_profiles(ProfileSearchParams { location_id: Some(brooklyn.id), ..Default::default() })?; println!("Found {} Recursers in Brooklyn", profiles.len());}
let profile = client.get_profile_by_id(12345)?;if let Some(location) = &profile.current_location { println!("{} is currently in {}", profile.name, location.name); if let Some(short_name) = &location.short_name { println!("Short name: {}", short_name); }}
fn get_location_id(client: &RcApiClient, query: &str) -> Option<u32> { let locations = client.search_locations(LocationSearchParams { query: query.to_string(), limit: Some(5), }).ok()?; if locations.is_empty() { println!("No locations found for: {}", query); return None; } println!("Select a location:"); for (i, loc) in locations.iter().enumerate() { println!(" {}. {} (ID: {})", i + 1, loc.name, loc.id); } // In a real app, you'd prompt the user to select Some(locations[0].id)}