Welcome to the Triathlon API
Developer Hub

Whether you are a researcher, media, or a fan, you'll find comprehensive guides and documentation to help you get up and running with the Triathlon API.

Read the docs Register & manage your app

Getting Started with Statistics API

The breadth of analysis types may make the Statistics API daunting to use so we have provided a few useful examples to demonstrate the API in action.

Of course you cannot perform all types of analysis from this API but you may use the data extraction as a starting point for building even richer analysis on top of the initial export (e.g. see the winning margins example below).

Additional Program Data

We are in the process of adding additional information to each of the programs such as atmospheric conditions, distances and other data. This will allow for an even deeper querying experience. Please see this update for further information.

Query Examples

How many WTS events have there been?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count_unique&target_property=event.name"

Which returns the following response (the answer is 53):

{  
   "code":200,
   "status":"success",
   "data":53
}

What is the average age of WTS winners vs. Format (Sprint vs Standard)?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=average&target_property=athlete.age&group_by=format|athlete.gender"

Which returns the average ages of Sprint and Standard distances winners grouped by format and gender.

{
   "code":200,
   "status":"success",
   "data":[
      {
         "athlete.gender":"female",
         "result":27.42723880597,
         "format":"Sprint"
      },
      {
         "athlete.gender":"male",
         "result":27.492091388401,
         "format":"Sprint"
      },
      {
         "athlete.gender":"female",
         "result":30.072972972973,
         "format":"Standard"
      },
      {
         "athlete.gender":"male",
         "result":29.991626794258,
         "format":"Standard"
      }
   ]
}

How many top 10 results have each nation obtained this year?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count&filters=position,lte,10&group_by=athlete.country|athlete.gender&timeframe=this_year"

What is the best ever World Triathlon Series finish for a Japanese male athlete?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=minimum&target_property=position&filters=athlete.country,eq,JPN|athlete.gender,eq,male"

This will return the result for the best finishing position (which is 7th at the time of writing). This leads naturally to the question, who and where was it? There are a couple of ways of answering that question... Firstly you could simply extract the best (i.e. minimum) finish for all Japanese athletes (by grouping by athlete.name and optionally event.name) and find the minimum position from the resulting array. Secondly, knowing the minimum finishing position you could construct a second query to find just the result(s) in question e.g.

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=minimum&target_property=position&filters=athlete.country,eq,JPN|athlete.gender,eq,male|position,eq,7&group_by=athlete.name|event.name"

This returns the required information (note: if more than one athlete had finished in 7th position, or it had occurred at multiple events, an array would have been returned of all 7th place finishes).

{  
   "code":200,
   "status":"success",
   "data":[  
      {  
         "event.name":"2012 ITU World Triathlon Madrid",
         "athlete.name":"Hirokatsu Tayama",
         "result":7
      }
   ]
}

How many of each World Triathlon Series medals does Alistair Brownlee have

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.name,eq,Alistair%20Brownlee|position,lte,3&group_by=position"
curl --header "apikey: [[app:key]]" https://proxy.api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.name,eq,Alistair%20Brownlee|position,lte,3&group_by=position|year
curl --header "apikey: [[app:key]]" https://proxy.api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.name,eq,Alistair%20Brownlee|position,lte,3&group_by=position|format

How many top 10 finishes have USA women had per year of the World Triathlon Series

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.country,eq,USA|athlete.gender,eq,female|position,lte,10&timeframe=this_7_years&interval=yearly"

Note: You could achieve the same result above simply by grouping by the year property but this example demonstrates the interval function.

Count how many times a group of athletes have raced

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.last,in,Brownlee,Mola,Frodeno"

How many results are without a swim time?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=splits.swim,exists,false"

When a property is not available you may check for it's existence with the exists filter. The majority of missing information is due to athletes not completing that section of the event. However there are certain instances where lost timing chips have caused a loss of data.

How does Jonathan Brownlee perform within 1000 miles of his hometown Leeds, UK?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count&filters=athlete.name,eq,Jonathan Brownlee|location,within,1000,53.801277,-1.548567&group_by=position"

Data Extraction

You won't be able to answer all your questions via a single API call e.g. what is the largest winning margin in a WTS race? In such cases you will need to extract the relevant data and either perform your own analysis of the results or script follow up queries to arrive at the final result. There are often a multitude of ways to solve the same problem and we will consider the simplest implementation to finding the largest winning margin:

First, list all WTS Events

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=count_unique&target_property=event.name&group_by=event.name|program.id|program.name"

With this query we have a list of all WTS races that have occurred including the unique program.id which may be used to extract the winning and second place times. We can then loop through each result making a call to each program.id and store the result.

Winning and second place times for each program

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=minimum&target_property=position&filters=program.id,eq,4818|position,lte,2&group_by=athlete.name|finish_time"

Clearly then it is a simple task of calculating the difference between the winning time and second place time for all programs and sorting by the difference (note: if you wish to check your working the result is Emma Snowsill at the 2010 Grand Final in Budapest where she bested Emma Moffatt by 102 seconds!)

Extract an athlete's results

We can use the group_by property to extract all the different information we require.

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=minimum&target_property=position&filters=athlete.name,eq,Gwen%20Jorgensen&group_by=event.name|date|format|event.id|finish_time&timeframe=this_year"

How does Richard Murray fare when wearing a wetsuit?

curl --header "apikey: [[app:key]]" "https://api.triathlon.org/v1/statistics/results?analysis=average&target_property=position&filters=athlete.name,eq,Richard%20Murray&group_by=program.wetsuit"

Need more ideas?

  • Is Javier Gomez Noya a morning or evening person? - compare an athlete's results based on the start time of the race (program.start_time)
  • How have the average swim times changed over the course of the Series?
  • Who peaks early in the year? - group athletes' results via months to spot trends

Getting Started with Statistics API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.