| Crates.io | ridewithgps-client |
| lib.rs | ridewithgps-client |
| version | 0.1.0 |
| created_at | 2025-12-30 23:11:30.249989+00 |
| updated_at | 2025-12-30 23:11:30.249989+00 |
| description | API client for the RideWithGPS routing and trip planning service |
| homepage | |
| repository | https://github.com/jelmer/ridewithgps-rs |
| max_upload_size | |
| id | 2013588 |
| size | 144,400 |
A Rust client library for the RideWithGPS API v1.
Add this to your Cargo.toml:
[dependencies]
ridewithgps-client = "0.1"
use ridewithgps_client::RideWithGpsClient;
// Create a client with API key only
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
// Or authenticate with email and password
let client = RideWithGpsClient::with_credentials(
"https://ridewithgps.com",
"your-api-key",
"user@example.com",
"password"
)?;
use ridewithgps_client::RideWithGpsClient;
let mut client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
// Create an auth token
let auth = client.create_auth_token("user@example.com", "password")?;
client.set_auth_token(&auth.auth_token);
use ridewithgps_client::{RideWithGpsClient, ListRoutesParams, Visibility};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
// List routes with filters
let params = ListRoutesParams {
min_distance: Some(10000.0), // 10km
visibility: Some(Visibility::Public),
..Default::default()
};
let routes = client.list_routes(Some(¶ms))?;
for route in routes.results {
println!("Route: {} - {:.2}km",
route.name.unwrap_or_default(),
route.distance.unwrap_or(0.0) / 1000.0
);
}
// Get a specific route
let route = client.get_route(12345)?;
// Get route polyline
let polyline = client.get_route_polyline(12345)?;
println!("Polyline: {}", polyline.polyline);
// Delete a route
client.delete_route(12345)?;
use ridewithgps_client::{RideWithGpsClient, ListTripsParams};
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
// List trips
let params = ListTripsParams {
min_distance: Some(20000.0), // 20km
..Default::default()
};
let trips = client.list_trips(Some(¶ms))?;
for trip in trips.results {
println!("Trip: {} - {:.2}km",
trip.name.unwrap_or_default(),
trip.distance.unwrap_or(0.0) / 1000.0
);
}
// Get a specific trip
let trip = client.get_trip(67890)?;
// Get trip polyline
let polyline = client.get_trip_polyline(67890)?;
// Delete a trip
client.delete_trip(67890)?;
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
None
);
// List all collections
let collections = client.list_collections(None)?;
for collection in collections.results {
println!("Collection: {} - {:?}",
collection.id,
collection.name.unwrap_or_default()
);
}
// Get a specific collection with all its routes and trips
let collection = client.get_collection(8094883)?;
println!("Collection: {:?}", collection.name);
println!("Description: {:?}", collection.description);
// Access routes within the collection
if let Some(routes) = &collection.routes {
println!("\nRoutes in collection:");
for route in routes {
println!(" Route {} - {:?} ({:.1}km)",
route.id,
route.name,
route.distance.unwrap_or(0.0) / 1000.0
);
}
}
// Access trips within the collection
if let Some(trips) = &collection.trips {
println!("\nTrips in collection:");
for trip in trips {
println!(" Trip {} - {:?} ({:.1}km)",
trip.id,
trip.name,
trip.distance.unwrap_or(0.0) / 1000.0
);
}
}
// Get the pinned collection (requires auth)
let client_auth = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
let pinned = client_auth.get_pinned_collection()?;
println!("Pinned collection: {:?}", pinned.name);
use ridewithgps_client::RideWithGpsClient;
let client = RideWithGpsClient::new(
"https://ridewithgps.com",
"your-api-key",
Some("your-auth-token")
);
// Get current user information
let user = client.get_current_user()?;
println!("User: {:?}", user);
Currently implemented endpoints:
POST /api/v1/auth_tokens - Create authentication tokenGET /api/v1/users/current - Get current userGET /api/v1/routes.json - List routesGET /api/v1/routes/{id}.json - Get routeGET /api/v1/routes/{id}/polyline.json - Get route polylineDELETE /api/v1/routes/{id}.json - Delete routeGET /api/v1/trips.json - List tripsGET /api/v1/trips/{id}.json - Get tripGET /api/v1/trips/{id}/polyline.json - Get trip polylineDELETE /api/v1/trips/{id}.json - Delete tripGET /api/v1/events.json - List eventsPOST /api/v1/events.json - Create eventGET /api/v1/events/{id}.json - Get eventPUT /api/v1/events/{id}.json - Update eventDELETE /api/v1/events/{id}.json - Delete eventGET /api/v1/collections.json - List collectionsGET /api/v1/collections/{id}.json - Get collectionGET /api/v1/collections/pinned.json - Get pinned collectionGET /api/v1/sync.json - Get changed items since datetimeGET /api/v1/points_of_interest.json - List POIsPOST /api/v1/points_of_interest.json - Create POIGET /api/v1/points_of_interest/{id}.json - Get POIPUT /api/v1/points_of_interest/{id}.json - Update POIDELETE /api/v1/points_of_interest/{id}.json - Delete POIPOST /api/v1/points_of_interest/{id}/routes/{route_id}.json - Associate POI with routeDELETE /api/v1/points_of_interest/{id}/routes/{route_id}.json - Disassociate POI from routeGET /api/v1/members.json - List membersGET /api/v1/members/{id}.json - Get memberPUT /api/v1/members/{id}.json - Update member permissions/statusLicensed under the Apache License, Version 2.0.
Contributions are welcome! Please feel free to submit a Pull Request.