Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more Got it

Register an app

Go to My Applications, Register an Application and login with your username and password. Give a name to your application (this is particulary useful in some flows), choose suitable values for client id and client secret fields or leave the defaults (they're automatically generated in a safe way by the system), choose a Public Client type and Resource owner password-based as Authorization grant type. For the OAuth2 flow you're going to use there's no need of any Redirect uris so you can leave that field blank. Hit save to finally register your application on the OAuth2 provider.

Grab your token

Now we need a token to access resources on the RunnerSquare server. We will ask for a token for our Application and your username and password; let's go there with curl:

curl -d "grant_type=password&client_id=<your_client_id>&username=<your_usermame>&password=<your_password>" https://www.runnersquare.com/o/token/

If everything goes smooth, server will answer with something like this:

{
    "refresh_token": "a_refresh_token_here", 
    "token_type": "Bearer", 
    "scope": "example", 
    "access_token": "the_access_token", 
    "expires_in": 36000
}

With the access token provided, we can authenticate against the server using Authorization header and providing our access token. In this example, we're going to access detailed data for our application through a proper endpoint:

curl -H "Authorization: Bearer the_access_token_here" https://www.runnersquare.com/rest/workouts/

API calls

GET

GET is used to retrieve data without directly modifying it.

Retrieving User workouts
Sample Request
GET /workouts HTTP/1.1
Host: runnersquare.com/rest
Authorization: Bearer the_access_token_here
Sample Response
HTTP/1.1 200 OK
Content-Type: 'application/json'

{'workouts': [<workout_id>,
  <workout_id>,
  ...
  <workout_id>,
  <workout_id>]}
Retrieving Workout details (.GPX file)
Sample Request
GET /workout/<workout_id>/ HTTP/1.1
Host: runnersquare.com/rest
Authorization: Bearer the_access_token_here
Sample Response
HTTP/1.1 200 OK
Content-Type: 'application/xml'
Content-Disposition: 'attachment; filename=RunnerSquare.gpx'

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/0" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd" creator="gpx.py -- https://github.com/tkrajina/gpxpy">
<trk>
<name>RunnerSquare</name>
<type/>
<desc/>
<trkseg>
<trkpt lat="41.480001490563154" lon="2.059104284271598">
<ele>141.0</ele>
<time>2014-10-23T05:02:17Z</time></trkpt>
...
<trkpt lat="41.47998958826065" lon="2.0592943858355284">
<ele>141.0</ele>
<time>2014-10-23T05:02:22Z</time></trkpt>
</trkseg></trk></gpx>