ridewithgps-client
A Rust client library for the RideWithGPS API v1.
Features
- Authentication with API key and auth tokens
- User management
- Route operations (list, get, get polyline, delete)
- Trip operations (list, get, get polyline, delete)
- Type-safe API with serde serialization
- Blocking HTTP client (async support planned)
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Usage
Basic Setup
use RideWithGpsClient;
// Create a client with API key only
let client = new;
// Or authenticate with email and password
let client = with_credentials?;
Authentication
use RideWithGpsClient;
let mut client = new;
// Create an auth token
let auth = client.create_auth_token?;
client.set_auth_token;
Working with Routes
use ;
let client = new;
// List routes with filters
let params = ListRoutesParams ;
let routes = client.list_routes?;
for route in routes.results
// Get a specific route
let route = client.get_route?;
// Get route polyline
let polyline = client.get_route_polyline?;
println!;
// Delete a route
client.delete_route?;
Working with Trips
use ;
let client = new;
// List trips
let params = ListTripsParams ;
let trips = client.list_trips?;
for trip in trips.results
// Get a specific trip
let trip = client.get_trip?;
// Get trip polyline
let polyline = client.get_trip_polyline?;
// Delete a trip
client.delete_trip?;
Working with Collections
use RideWithGpsClient;
let client = new;
// List all collections
let collections = client.list_collections?;
for collection in collections.results
// Get a specific collection with all its routes and trips
let collection = client.get_collection?;
println!;
println!;
// Access routes within the collection
if let Some = &collection.routes
// Access trips within the collection
if let Some = &collection.trips
// Get the pinned collection (requires auth)
let client_auth = new;
let pinned = client_auth.get_pinned_collection?;
println!;
Working with Users
use RideWithGpsClient;
let client = new;
// Get current user information
let user = client.get_current_user?;
println!;
API Coverage
Currently implemented endpoints:
Authentication & Users
POST /api/v1/auth_tokens- Create authentication tokenGET /api/v1/users/current- Get current user
Routes
GET /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 route
Trips
GET /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 trip
Events
GET /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 event
Collections
GET /api/v1/collections.json- List collectionsGET /api/v1/collections/{id}.json- Get collectionGET /api/v1/collections/pinned.json- Get pinned collection
Sync
GET /api/v1/sync.json- Get changed items since datetime
Points of Interest (organization-only)
GET /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 route
Club Members (organization-only)
GET /api/v1/members.json- List membersGET /api/v1/members/{id}.json- Get memberPUT /api/v1/members/{id}.json- Update member permissions/status
License
Licensed under the Apache License, Version 2.0.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.