Making your First Statistics API Query

This simple guide will walk you through making a simple query to the Statistics API using the Advanced REST client tool for the Chrome browser.

Once you have installed the tool launch the application from Chrome .

Next enter the following URL into the address bar. This query will return the number of top 10 female finishes for each country for the current season.

https://api.triathlon.org/v1/statistics/results?analysis=count&filters=position,lte,10|athlete.gender,eq,female&group_by=athlete.country&timeframe=this_year

You will need to provide authentication information. To do this simply add a new header with the key of apikey and the value as your personal API key obtained from the International Triathlon Union. You may use the form helper provided by the Advanced Rest client tool to generate this header. The following image displays what you should see after completing these two steps (obviously replacing the enter_your_api_key_here with your own personal key).

1090

Adding query URL and authentication information

Then simply click 'send' and you will obtain a result as per the following example which lists each country (based on IOC country codes) and the result, which is the number of top 10 finishes each country has had.

{
   "code":200,
   "status":"success",
   "data":[
      {
         "result":4,
         "athlete.country":"AUS"
      },
      {
         "result":1,
         "athlete.country":"AUT"
      },
      {
         "result":2,
         "athlete.country":"BER"
      },
      {
         "result":1,
         "athlete.country":"BRA"
      },
      {
         "result":3,
         "athlete.country":"CAN"
      },
      {
         "result":3,
         "athlete.country":"CHI"
      },
      {
         "result":1,
         "athlete.country":"CZE"
      },
      {
         "result":5,
         "athlete.country":"GBR"
      },
      {
         "result":4,
         "athlete.country":"GER"
      },
      {
         "result":3,
         "athlete.country":"IRL"
      },
      {
         "result":2,
         "athlete.country":"JPN"
      },
      {
         "result":2,
         "athlete.country":"NED"
      },
      {
         "result":6,
         "athlete.country":"NZL"
      },
      {
         "result":1,
         "athlete.country":"RSA"
      },
      {
         "result":1,
         "athlete.country":"SUI"
      },
      {
         "result":21,
         "athlete.country":"USA"
      }
   ]
}

If you are not familiar with JSON and would prefer to export the data to a spreadsheet you may use an online tool to convert the JSON to CSV which you may then import directly to your favourite spreadsheet program.

Now you have made your first query, check out our Getting Started guide to delve into some more advanced query types and examples.