{"id":16777076,"url":"https://github.com/mpclarkson/stravaswift","last_synced_at":"2025-03-17T02:31:37.322Z","repository":{"id":41420113,"uuid":"59529791","full_name":"mpclarkson/StravaSwift","owner":"mpclarkson","description":"A Swift wrapper for the Strava API v3","archived":false,"fork":false,"pushed_at":"2024-03-25T02:15:54.000Z","size":557,"stargazers_count":98,"open_issues_count":19,"forks_count":45,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-25T06:21:10.876Z","etag":null,"topics":["strava","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpclarkson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-05-24T01:18:14.000Z","updated_at":"2024-04-02T19:28:44.000Z","dependencies_parsed_at":"2024-03-25T03:39:30.664Z","dependency_job_id":null,"html_url":"https://github.com/mpclarkson/StravaSwift","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpclarkson%2FStravaSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpclarkson%2FStravaSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpclarkson%2FStravaSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpclarkson%2FStravaSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpclarkson","download_url":"https://codeload.github.com/mpclarkson/StravaSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841125,"owners_count":20356440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["strava","swift"],"created_at":"2024-10-13T07:23:24.410Z","updated_at":"2025-03-17T02:31:36.707Z","avatar_url":"https://github.com/mpclarkson.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StravaSwift\n\n[![CI Status](http://img.shields.io/travis/mpclarkson/StravaSwift.svg?style=flat)](https://travis-ci.org/mpclarkson/StravaSwift)\n[![codebeat badge](https://codebeat.co/badges/d58ef23f-b2c6-45df-83cb-35af96b6980d)](https://codebeat.co/projects/github-com-mpclarkson-stravaswift)\n[![Version](https://img.shields.io/cocoapods/v/StravaSwift.svg?style=flat)](http://cocoapods.org/pods/StravaSwift)\n[![License](https://img.shields.io/cocoapods/l/StravaSwift.svg?style=flat)](http://cocoapods.org/pods/StravaSwift)\n[![Platform](https://img.shields.io/cocoapods/p/StravaSwift.svg?style=flat)](http://cocoapods.org/pods/StravaSwift)\n\nThis is a Swift wrapper for the [Strava v3 API](https://strava.github.io/api/).\n\nAs 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.\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Installation\n\n[StravaSwift](https://github.com/mpclarkson/StravaSwift) is available through the [Swift Package Manager](https://swift.org/package-manager/) and [CocoaPods](http://cocoapods.org).\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/mpclarkson/StravaSwift.git\", from: \"1.0.1\")\n]\n```\n\n### Cocoapods\n\nTo install it, simply add the following line to your Podfile:\n\n```ruby\npod \"StravaSwift\", '~\u003e 1.0.1'\n```\n\n## Quick Start\n\nThe full library documentation is available [here](http://cocoadocs.org/docsets/StravaSwift).\n\n* First, you must [register your app](http://labs.strava.com/developers/) with Strava and get an OAuth `client id` and `client secret`.\n\n* Initialize the Strava Client as follows, preferably in your `AppDelegate.swift` to ensure it is configured before you call it:\n\n```swift\nlet config = StravaConfig(\n    clientId: YourStravaClientId,\n    clientSecret: YourStravaClientSecret,\n    redirectUri: YourRedirectUrl\n)\n\nStravaClient.sharedInstance.initWithConfig(config)\n```\n\n* 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.\n\n* Register your redirect URL scheme in your `info.plist` file.\n\n* The authentication will use the Strava app be default if it is installed on the device. If the user does not have Strava installed, it will fallback on `SFAuthenticationSession` or `ASWebAuthenticationSession` depending on the iOS version. If your app is linked on or after iOS 9.0, you must add `strava` in you app’s `info.plist` file. It should be added as an entry fo the array under the `LSApplicationQueriesSchemes` key. Failure to do this will result in a crash when calling `canOpenUrl:`.\n\n```xml\n\u003ckey\u003eLSApplicationQueriesSchemes\u003c/key\u003e\n\u003carray\u003e\n    \u003cstring\u003estrava\u003c/string\u003e\n\u003c/array\u003e\n```\n\n* Implement the following method in your `AppDelegate.swift` to handle the OAuth redirection from Strava:\n\n```swift\nlet strava = StravaClient.sharedInstance\n\nfunc application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -\u003e Bool {\n    return strava.handleAuthorizationRedirect(url)\n}\n```\n\n* After authorizing, you can start requesting resources:\n\n```swift\nstrava.authorize() { result in\n    switch result {\n        case .success(let token):\n            //do something for success\n        case .failure(let error):\n            //do something for error\n    }\n}\n```\n\n* Requesting resources:\n\n\u003e The Router implementation is based on this\nAlamofire [example](https://github.com/Alamofire/Alamofire#api-parameter-abstraction):\n\n```swift\nstrava.request(Router.athletes(id: 9999999999)) { (athlete: Athlete?) in\n    //do something with the athlete\n}\n\nlet params = [\n    'page' = 2,\n    'per_page' = 25\n]\n\nstrava.request(Router.athleteActivities(params: params) { (activities: [Activity]?) in\n   //do something with the activities\n}\n```\n\n## Todos\n\n- [ ] 100% API coverage (about 90% now)\n- [ ] Documentation\n- [ ] Tests\n- [ ] Better example app\n\n## Author\n\nMatthew Clarkson, mpclarkson@gmail.com\n\n## License\n\nStravaSwift is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpclarkson%2Fstravaswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpclarkson%2Fstravaswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpclarkson%2Fstravaswift/lists"}