Strava API Wrapper
An asynchronous wrapper for the Strava API, written in Rust.
Builder-style, trait-driven, and covers the full public v3 surface: activities, athletes, clubs, gear, routes, segments, segment efforts, streams, and uploads, plus the OAuth token and deauthorize flows.
Installation
[]
= "0.1.0"
= { = "1", = ["macros", "rt-multi-thread"] }
Quick start
use StravaAPI;
use *;
async
OAuth
use ;
// 1. Exchange authorization code for an access token.
let token = get_token.await?;
// 2. Later, swap a soon-to-expire access token for a new one.
let refreshed = refresh_token.await?;
api.set_token;
// 3. Revoke access on logout.
deauthorize.await?;
Writes
use ;
// Create a manual activity.
api.activities.create.send.await?;
// Update fields on an existing activity.
api.activities.update.send.await?;
// Star a segment.
api.segments.star.send.await?;
// Update weight.
api.athlete.update.send.await?;
Streams
use StreamKey;
let streams = api
.streams
.activity
.id
.keys
.send
.await?;
Uploads
use UploadDataType;
let bytes = read?;
let upload = api
.uploads
.upload
.name
.send
.await?;
// Poll processing status.
let status = api.uploads.get.id.send.await?;
Errors
All network calls return Result<T, ErrorWrapper>. ErrorWrapper is an enum with Network, Parse, Api, and Url variants and implements Display + std::error::Error, so it composes with ? in your own error types.
Testing