Being a Cyclist and a Geek, I like to track things. Being a Sys Admin and a Programmer I also like this to happen in the most efficient manner possible. Insert Strava, which is basically a social networking platform for cyclists/runners/swimmers (I believe they're adding more as well). Strava has an App for recording things or you can use any app or device that can output in one of the supported formats (GPX, FIT and TCX).

Strava also has an api and I was looking to implement something for Exobrain and noted that whilst a Perl Client existed for Strava it was based on V2 API which no longer exists. So after pinging the Maintainer I was given co-maint on WebService::Strava and today I was able to release my first module on cpan!

Probably the easiest way to install it is via cpanm + local::lib. On an Ubuntu distro you can grab these with apt:

sudo apt-get install cpanminus liblocal-lib-perl

Then you can configure local::lib

$ perl -Mlocal::lib >> ~/.bashrc
$ eval $(perl -Mlocal::lib)

then install WebService::Strava

cpanm WebService::Strava

Once installed you will need to configure your authentication. After setting up your application in your profile just run

strava --setup

It will ask for your client id, client secret and authenticate with the strava api. You will have to copy the 'code' from the url bar as Strava doesn't yet implement 'urn:ietf:wg:oauth:2.0:oob' standard for scripts.

After which you can in a few lines access most of the API

use strict;
use feature qw(say);
use WebService::Strava;

my $strava = WebService::Strava->new();

my $athlete = $strava->athlete();

say $athlete->firstname;

Which outputs

[email protected]:/tmp$ perl 

Full documentation is available on cpan and you can contribute, ask for features on github

This content is available for you to use for free, even commercially, under a Creative Commons Attribution 4.0 International License

If you wish to support my work, please tip me on gittip.


comments powered by Disqus