Latest 0.7.0
License MIT
Platforms ios 9.0
Dependencies Alamofire, SwiftyJSON

CI Status
codebeat badge

This is a Swift wrapper for the Strava v3 API.

As this is a passion project, I only work on it when I have time. So, if you are interested in contributing, feel free to submit PRs.


To run the example project, clone the repo, and run pod install from the Example directory first.


StravaSwift is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "StravaSwift"

Quick Start

The full library documentation is available here.

  • First, you must register your app with Strava and get an oAuth client id and client secret.

  • Initialize the Strava Client as follows, preferably in your AppDelegate.swift to ensure it is configured before you call it:
let config = StravaConfig(
    clientId: YourStravaClientId,
    clientSecret: YourStravaClientSecret,
    redirectUri: YourRedirectUrl

  • Note, by default the oAuth token is only available while the app is running, which means you need to request a new token. You can implement custom token storage and retrieval behaviour by overriding the default token delegate in the StravaConfig initializer which must implement the TokenDelegate protocol.

  • Register your redirect URL scheme in your info.plist.

  • Implement the following method in your AppDelegate.swift to handle the oAuth redirection from Strava:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    guard let code = strava?.handleAuthorizationRedirect(url) else { return false }
    //Exchange the code for a token
    strava.getAccessToken(code) { token in
        //Do something if you want, but the token is already available to the
        //StravaClient thanks to the TokenDelegate
    return true
  • Now you can start requesting resources.

The Router implementation is based on this
Alamofire example:

let strava = StravaClient.sharedInstance

strava.request(Router.Athletes(id: 9999999999)) { (athlete: Athlete?) in
    //do something with the athlete

let params = [
    'page' = 2,
    'per_page' = 25

strava.request(Router.AthleteActivities(params: params) { (activities: [Activity]?) in
   //do something with the activities


  • [ ] 100% API coverage (about 90% now)
  • [ ] Documentation
  • [ ] Tests
  • [ ] Better example app


Matthew Clarkson, [email protected]


StravaSwift is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "StravaSwift",
    "version": "0.7.0",
    "summary": "A Swift library for the Strava API v3",
    "description": "A Swift library for the Strava API v3. For complete details visit the Strava developer site.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Matthew Clarkson": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.7.0"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source_files": "StravaSwift/**/*",
    "dependencies": {
        "Alamofire": [
            "~> 4"
        "SwiftyJSON": [
            "~> 3"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This