The strive package

[Tags: library, mit]

A Haskell client for the Strava V3 API.

Check out the readme for complete documentation.


[Skip to ReadMe]

Properties

Versions0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.7.1, 0.8.0, 1.0.0, 1.0.1, 2.0.0, 2.0.1, 2.1.0
Change logCHANGELOG.md
Dependenciesaeson (==0.7.*), base (==4.*), bytestring (==0.10.*), data-default (==0.5.*), Glob (==0.7.*), gpolyline (==0.1.*), http-conduit (==2.*), http-types (==0.8.*), regex-compat (==0.95.*), template-haskell (==2.*), text (==0.11.* || ==1.*), time (==1.*), transformers (==0.3.*) [details]
LicenseMIT
Copyright2014 Taylor Fausak <taylor@fausak.me>
AuthorTaylor Fausak
Maintainertaylor@fausak.me
CategoryAPI
Home pagehttp://taylor.fausak.me/strive/
Bug trackerhttps://github.com/tfausak/strive/issues
Source repositoryhead: git clone git://github.com/tfausak/strive.git
UploadedTue Aug 12 13:04:44 UTC 2014 by fozworth
DistributionsNixOS:2.1.0
Downloads854 total (69 in last 30 days)
Votes
0 []
StatusDocs available [build log]
Successful builds reported [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for strive-0.6.1

[Strive][1]

Hackage Version Build Status

A Haskell client for the [Strava V3 API][2].

Installation

Add it to your Cabal file:

library
  build-depends:
    strive ==0.6.*

Or install it manually:

$ cabal update
$ cabal install strive

This package uses [Semantic Versioning][3].

Usage

To use the API, you'll need an access token. Once you have that, create a new client using the default HTTP manager.

import Strive
let token = "a token"
client <- buildClient token

Most types implement lenses for their fields. Lenses are preferred over directly accessing the fields. For instance, instead of doing this:

client_accessToken (client { client_accessToken = "record token" })
-- "record token"

Do this:

get accessToken (set accessToken "lens token" client)
-- "lens token"
<!-- ~~~ {.haskell} import Data.ByteString.Char8 (pack) import Data.Time.Calendar (fromGregorian) import Data.Time.Clock (UTCTime (UTCTime)) import Strive import System.Exit (exitSuccess)

main :: IO () main = do _ <- exitSuccess client <- buildClient "token"

-->

### [Authentication](http://strava.github.io/api/v3/oauth/)

#### [Request access](http://strava.github.io/api/v3/oauth/#get-authorize)

let authorizeUrl = buildAuthorizeUrl 1790 "http://localhost" $ with [ set approvalPrompt False , set privateScope True , set writeScope True , set state "..." ] print (authorizeUrl :: String)


#### [Token exchange](http://strava.github.io/api/v3/oauth/#post-token)

tokenExchangeResponse <- exchangeToken 1790 "secret" "code" print (tokenExchangeResponse :: Either String TokenExchangeResponse)


#### [Deauthorization](http://strava.github.io/api/v3/oauth/#deauthorize)

deauthorizationResponse <- deauthorize client print (deauthorizationResponse :: Either String DeauthorizationResponse)


### [Athletes](http://strava.github.io/api/v3/athlete/)

#### [Retrieve current athlete](http://strava.github.io/api/v3/athlete/#get-details)

currentAthlete <- getCurrentAthlete client print (currentAthlete :: Either String AthleteDetailed)


#### [Retrieve another athlete](http://strava.github.io/api/v3/athlete/#get-another-details)

anotherAthlete <- getAthlete client 65516 print (anotherAthlete :: Either String AthleteSummary)


#### [Update current athlete](http://strava.github.io/api/v3/athlete/#update)

updatedAthlete <- updateCurrentAthlete client $ with [ set city (Just "Dallas") , set state (Just "Texas") , set country (Just "United States") , set sex (Just Male) , set weight (Just 72.57) ] print (updatedAthlete :: Either String AthleteDetailed)


#### [List athlete K/QOMs/CRs](http://strava.github.io/api/v3/athlete/#koms)

athleteCrs <- getAthleteCrs client 65516 $ with [ set page 1 , set perPage 2 ] print (athleteCrs :: Either String [EffortDetailed])


### [Friends and followers](http://strava.github.io/api/v3/follow/)

#### [List athlete friends](http://strava.github.io/api/v3/follow/#friends)

currentFriends <- getCurrentFriends client $ with [ set page 1 , set perPage 2 ] print (currentFriends :: Either String [AthleteSummary])


friends <- getFriends client 65516 $ with [ set page 1 , set perPage 2 ] print (friends :: Either String [AthleteSummary])


#### [List athlete followers](http://strava.github.io/api/v3/follow/#followers)

currentFollowers <- getCurrentFollowers client $ with [ set page 1 , set perPage 2 ] print (currentFollowers :: Either String [AthleteSummary])


followers <- getFollowers client 65516 $ with [ set page 1 , set perPage 2 ] print (followers :: Either String [AthleteSummary])


#### [List both following](http://strava.github.io/api/v3/follow/#both)

commonFriends <- getCommonFriends client 65516 $ with [ set page 1 , set perPage 2 ] print (commonFriends :: Either String [AthleteSummary])


### [Activities](http://strava.github.io/api/v3/activities/)

#### [Create an activity](http://strava.github.io/api/v3/activities/#create)

createdActivity <- createActivity client "An Example" "run" (UTCTime (fromGregorian 1970 0 0) 0) 10 $ with [ set description (Just "...") , set distance (Just 100.0) ] print (createdActivity :: Either String ActivityDetailed)


#### [Retrieve an activity](http://strava.github.io/api/v3/activities/#get-details)

activity <- getActivity client 141273622 $ with [ set allEfforts True ] print (activity :: Either String ActivitySummary)


#### [Update an activity](http://strava.github.io/api/v3/activities/#put-updates)

updatedActivity <- updateActivity client 141273622 $ with [ set name (Just "WedEx Pit Stop") , set Strive.type (Just Ride) , set private (Just False) , set commute (Just True) , set trainer (Just False) , set gearId (Just "b387882") , set description Nothing ] print (updatedActivity :: Either String ActivityDetailed)


#### [Delete an activity](http://strava.github.io/api/v3/activities/#delete)

nothing <- deleteActivity client 162674281 print (nothing :: Either String ())


#### [List athlete activities](http://strava.github.io/api/v3/activities/#get-activities)

currentActivities <- getCurrentActivities client $ with [ set before (Just (UTCTime (fromGregorian 1970 0 0) 0)) , set after (Just (UTCTime (fromGregorian 1970 0 0) 0)) , set page 1 , set perPage 2 ] print (currentActivities :: Either String [ActivitySummary])


#### [List friends' activities](http://strava.github.io/api/v3/activities/#get-feed)

feed <- getFeed client $ with [ set page 1 , set perPage 2 ] print (feed :: Either String [ActivitySummary])


#### [List activity zones](http://strava.github.io/api/v3/activities/#zones)

activityZones <- getActivityZones client 141273622 print (activityZones :: Either String [ActivityZoneDetailed])


#### [List activity laps](http://strava.github.io/api/v3/activities/#laps)

activityLaps <- getActivityLaps client 141273622 print (activityLaps :: Either String [ActivityLapSummary])


### [Comments](http://strava.github.io/api/v3/comments/)

#### [List activity comments](http://strava.github.io/api/v3/comments/#list)

activityComments <- getActivityComments client 90112360 $ with [ set markdown True , set page 1 , set perPage 2 ] print (activityComments :: Either String [CommentSummary])


### [Kudos](http://strava.github.io/api/v3/kudos/)

#### [List activity kudoers](http://strava.github.io/api/v3/kudos/#list)

activityKudoers <- getActivityKudoers client 141273622 $ with [ set page 1 , set perPage 2 ] print (activityKudoers :: Either String [AthleteSummary])


### [Photos](http://strava.github.io/api/v3/photos/)

#### [List activity photos](http://strava.github.io/api/v3/photos/#list)

activityPhotos <- getActivityPhotos client 141273622 print (activityPhotos :: Either String [PhotoSummary])


### [Clubs](http://strava.github.io/api/v3/clubs/)

#### [Retrieve a club](http://strava.github.io/api/v3/clubs/#get-details)

club <- getClub client 11193 print (club :: Either String ClubDetailed)


#### [List athlete clubs](http://strava.github.io/api/v3/clubs/#get-athletes)

currentClubs <- getCurrentClubs client print (currentClubs :: Either String [ClubSummary])


#### [List club members](http://strava.github.io/api/v3/clubs/#get-members)

clubMembers <- getClubMembers client 11193 $ with [ set page 1 , set perPage 2 ] print (clubMembers :: Either String [AthleteSummary])


#### [List club activities](http://strava.github.io/api/v3/clubs/#get-activities)

clubActivities <- getClubActivities client 11193 $ with [ set page 1 , set perPage 2 ] print (clubActivities :: Either String [ActivitySummary])


### [Gear](http://strava.github.io/api/v3/gear/)

#### [Retrieve gear](http://strava.github.io/api/v3/gear/#show)

theGear <- getGear client "b387855" print (theGear :: Either String GearDetailed)


### [Segments](http://strava.github.io/api/v3/segments/)

#### [Retrieve a segment](http://strava.github.io/api/v3/segments/#retrieve)

theSegment <- getSegment client 4773104 print (theSegment :: Either String SegmentDetailed)


#### [List starred segments](http://strava.github.io/api/v3/segments/#starred)

starredSegments <- getStarredSegments client $ with [ set page 1 , set perPage 2 ] print (starredSegments :: Either String [SegmentSummary])


#### [List efforts](http://strava.github.io/api/v3/segments/#efforts)

theSegmentEfforts <- getSegmentEfforts client 4773104 $ with [ set athleteId (Just 65516) , set range (Just ((UTCTime (fromGregorian 1970 0 0) 0), (UTCTime (fromGregorian 1970 0 0) 0))) , set page 1 , set perPage 2 ] print (theSegmentEfforts :: Either String [EffortDetailed])


#### [Segment leaderboard](http://strava.github.io/api/v3/segments/#leaderboard)

segmentLeaderboardResponse <- getSegmentLeaderboard client 4773104 $ with [ set gender (Just Male) , set ageGroup (Just Ages0To24) , set weightClass (Just Kilograms65To74) , set following (Just True) , set clubId (Just 11193) , set dateRange (Just "this_year") , set page 1 , set perPage 2 ] print (segmentLeaderboardResponse :: Either String SegmentLeaderboardResponse)


#### [Segment explorer](http://strava.github.io/api/v3/segments/#explore)

segmentExplorerResponse <- exploreSegments client (32.0, -96.0, 33.0, -95.0) $ with [ set activityType Riding , set minCat 0 , set maxCat 5 ] print (segmentExplorerResponse :: Either String SegmentExplorerResponse)


### [Segment efforts](http://strava.github.io/api/v3/efforts/)

#### [Retrieve a segment effort](http://strava.github.io/api/v3/efforts/#retrieve)

segmentEffort <- getSegmentEffort client 1595370098 print (segmentEffort :: Either String EffortDetailed)


### [Streams](http://strava.github.io/api/v3/streams/)

#### [Retrieve activity streams](http://strava.github.io/api/v3/streams/#activity)

activityStreams <- getActivityStreams client 141273622 [LatlngStream, WattsStream] $ with [ set resolution (Just Low) , set seriesType Time ] print (activityStreams :: Either String [StreamDetailed])


#### [Retrieve effort streams](http://strava.github.io/api/v3/streams/#effort)

effortStreams <- getEffortStreams client 1595370098 [LatlngStream, WattsStream] $ with [ set resolution (Just Low) , set seriesType Time ] print (effortStreams :: Either String [StreamDetailed])


#### [Retrieve segment streams](http://strava.github.io/api/v3/streams/#segment)

segmentStreams <- getSegmentStreams client 4773104 [LatlngStream, WattsStream] $ with [ set resolution (Just Low) , set seriesType Time ] print (segmentStreams :: Either String [StreamDetailed])


### [Uploads](http://strava.github.io/api/v3/uploads/)

#### [Upload an activity](http://strava.github.io/api/v3/uploads/#post-file)

uploadedActivity <- uploadActivity client (pack "...") "gpx.gz" $ with [ set activityType (Just Ride) , set name (Just "An Example") , set description (Just "...") , set private True , set trainer False , set externalId (Just "...") ] print (uploadedActivity :: Either String UploadStatus)


#### [Check upload status](http://strava.github.io/api/v3/uploads/#get-status)

upload <- getUpload client 16486788 print (upload :: Either String UploadStatus)


[1]: https://github.com/tfausak/strive
[2]: http://strava.github.io/api/
[3]: http://semver.org/spec/v2.0.0.html