{"_id":"564a63e8eed7de0d003671d7","user":"546d17e2eb9cfd1400dd4529","version":{"_id":"55773a5ba042551900b002ce","project":"55773a5ba042551900b002cb","__v":18,"createdAt":"2015-06-09T19:11:23.764Z","releaseDate":"2015-06-09T19:11:23.764Z","categories":["55773a5ca042551900b002cf","55773a6ce6063e0d00481380","55773ab007e7110d001043ec","55773abaa042551900b002d5","55773ac207e7110d001043ed","55773acb07e7110d001043ee","55773ad3a042551900b002d6","55773adce6063e0d00481383","55773ae4a042551900b002d7","55773af307e7110d001043ef","55773af907e7110d001043f0","55773b0407e7110d001043f1","563a4f7ad25e8919005f3f39","563a4fcaa19edf0d00972321","564a70dc4cd0521700523edf","564b797bcc472d0d00da9435","564b855b766d4923004e1fd1","59cd4b81935249001c77c48e"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Motherboard","version_clean":"1.0.0","version":"1"},"category":{"_id":"55773a6ce6063e0d00481380","pages":["55773a9fe6063e0d00481381","5638e57daaddb90d00c75fd1","564a61684cd0521700523ebf","564a629ceed7de0d003671d3","564a631a4721851900a675dc","564a63974721851900a675e4","564a63e8eed7de0d003671d7","564a9eb4e5d9d61700d57fe7","566731f5d784a70d00397cd4"],"project":"55773a5ba042551900b002cb","version":"55773a5ba042551900b002ce","__v":9,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-06-09T19:11:40.967Z","from_sync":false,"order":9,"slug":"statistics-api","title":"Statistics API"},"project":"55773a5ba042551900b002cb","editedParams":true,"editedParams2":true,"__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-16T23:16:56.419Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"method":"get","results":{"codes":[]},"settings":"","examples":{"codes":[]},"auth":"required","params":[{"_id":"564a63e8eed7de0d003671d9","ref":"","in":"query","required":true,"desc":"A single filter to determine the athletes to analyse","default":"","type":"string","name":"athletes"},{"_id":"564a63e8eed7de0d003671d8","ref":"","in":"query","required":false,"desc":"A list of filters to narrow down the events used in an analysis request based on event property values","default":"","type":"string","name":"filters"}],"url":"/statistics/matchups"},"isReference":true,"order":4,"body":"The Matchups endpoint allows you to determine the relative **head-to-head** results for a group of athletes.\n\nThe required athletes parameter should contain a filter to determine a list of athletes for analysis. You may use any of the available [athlete properties](http://statistics.triathlon.org/v1.0/docs/results) to create your athlete grouping (i.e. athlete.id, athlete.name, athlete.first, athlete.last). So long as the athlete filter resolves to a set of athletes any filter is acceptable.\n\nFor example to get a head-to-head matchup of Javier Gomez Noya and Alistair Brownlee we could make the following query:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl --header \\\"apikey: [[app:key]]\\\" \\\"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya\\\"\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nAlternatively using the athlete.id property:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl --header \\\"apikey: [[app:key]]\\\" \\\"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.id,in,7788,5695\\\"\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nThe API call will return an object with a **total_matchups** property which is the number of times that these athletes have raced in the same events matching the chosen criteria (see [additional filters ](http://statistics.triathlon.org/v1.0/docs/matchups#using-filters) section). In addition the resulting athletes array lists all athletes used in the analysis together with the number of wins, losses and no-results for the matching events.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Wins vs Losses vs No Results\",\n  \"body\": \"As we are considering matchups a '*win*' is finishing ahead of all other athletes in the group (and not necessarily a race win). A *no result* can only occur when all athletes in the group do not complete, or are disqualified from the event. The Matchup endpoint is specifically for relative performance to a group and if you require absolute analysis types (such as number of race wins) you should use the primary [Results endpoint](http://statistics.triathlon.org/v1.0/docs/results).\"\n}\n[/block]\n*The following example only shows a single result in the matchup_results array for brevity. The actual response would contain all 27 results.* \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   \\\"code\\\":200,\\n   \\\"status\\\":\\\"success\\\",\\n   \\\"data\\\":{\\n      \\\"total_matchups\\\":27,\\n      \\\"athletes\\\":[\\n         {\\n            \\\"wins\\\":7,\\n            \\\"losses\\\":20,\\n            \\\"no_results\\\":0,\\n            \\\"athlete_id\\\":5695,\\n            \\\"athlete_title\\\":\\\"Javier Gomez Noya\\\",\\n            \\\"athlete_first\\\":\\\"Javier\\\",\\n            \\\"athlete_last\\\":\\\"Gomez Noya\\\",\\n            \\\"athlete_gender\\\":\\\"male\\\",\\n            \\\"athlete_age\\\":32,\\n            \\\"athlete_country\\\":\\\"ESP\\\",\\n            \\\"athlete_flag\\\":\\\"https:\\\\/\\\\/f9ca11ef49c28681fc01-0acbf57e00c47a50e70a1acb89e86c89.ssl.cf1.rackcdn.com\\\\/images\\\\/icons\\\\/es.png\\\",\\n            \\\"athlete_profile_image\\\":\\\"http:\\\\/\\\\/www.triathlon.org\\\\/images\\\\/athlete_thumbs\\\\/Gomez.png\\\",\\n            \\\"wts_ranking\\\":1,\\n            \\\"wts_starts\\\":44,\\n            \\\"wts_wins\\\":11,\\n            \\\"wts_podiums\\\":32,\\n            \\\"matchup_results\\\":[\\n               {\\n                  \\\"format\\\":\\\"Standard\\\",\\n                  \\\"finish_time\\\":6738,\\n                  \\\"program.id\\\":4538,\\n                  \\\"event.name\\\":\\\"2009 Dextro Energy Triathlon - ITU World Championship Series Madrid\\\",\\n                  \\\"date\\\":\\\"2009-05-31T14:14:00+0000\\\",\\n                  \\\"position\\\":3\\n               },\\n              //...... other results ......//\\n            ]\\n         },\\n         {\\n            \\\"wins\\\":20,\\n            \\\"losses\\\":7,\\n            \\\"no_results\\\":0,\\n            \\\"athlete_id\\\":7788,\\n            \\\"athlete_title\\\":\\\"Alistair Brownlee\\\",\\n            \\\"athlete_first\\\":\\\"Alistair\\\",\\n            \\\"athlete_last\\\":\\\"Brownlee\\\",\\n            \\\"athlete_gender\\\":\\\"male\\\",\\n            \\\"athlete_age\\\":27,\\n            \\\"athlete_country\\\":\\\"GBR\\\",\\n            \\\"athlete_flag\\\":\\\"https:\\\\/\\\\/f9ca11ef49c28681fc01-0acbf57e00c47a50e70a1acb89e86c89.ssl.cf1.rackcdn.com\\\\/images\\\\/icons\\\\/gb.png\\\",\\n            \\\"athlete_profile_image\\\":\\\"http:\\\\/\\\\/www.triathlon.org\\\\/images\\\\/athlete_thumbs\\\\/Brownlee.png\\\",\\n            \\\"wts_ranking\\\":5,\\n            \\\"wts_starts\\\":29,\\n            \\\"wts_wins\\\":19,\\n            \\\"wts_podiums\\\":23,\\n            \\\"matchup_results\\\":[\\n               {\\n                  \\\"format\\\":\\\"Standard\\\",\\n                  \\\"finish_time\\\":6686,\\n                  \\\"program.id\\\":4538,\\n                  \\\"event.name\\\":\\\"2009 Dextro Energy Triathlon - ITU World Championship Series Madrid\\\",\\n                  \\\"date\\\":\\\"2009-05-31T14:14:00+0000\\\",\\n                  \\\"position\\\":1\\n               },\\n              //...... other results ......//\\n\\t            ]\\n         }\\n      ]\\n   }\\n}\",\n      \"language\": \"json\",\n      \"name\": null\n    }\n  ]\n}\n[/block]\nYou are not limited to analysing two athletes and a group may be conceivably as large as you wish. The following example adds Jonathan Brownlee to the previous query. This will return all results where all three athletes have raced and determine the winner of each event as the first finisher of the three.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl --header \\\"apikey: [[app:key]]\\\" \\\"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya,Jonathan%20Brownlee\\\"\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\n\nIf you enter a query where no matchups have occurred, such as where a group of athletes have never raced each other, you will be returned a 400 response as per the following example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   \\\"code\\\":400,\\n   \\\"status\\\":\\\"fail\\\",\\n   \\\"data\\\":{\\n      \\\"error\\\":\\\"This matchup has not occurred\\\"\\n   }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Additional Filters\"\n}\n[/block]\nWhilst analyzing all results for an athlete grouping is an excellent starting point, sometimes you may wish to delve deeper into the analysis e.g. what is the matchup over a specific course? How does a matchup vary over format (Sprint vs. Standard)? How does wearing a wetsuit affect the matchup?\n\nFor this type of analysis we have the entire [filter property](http://statistics.triathlon.org/#filters) at our disposal and we can combine as complex a filter as we wish, for example events in Hamburg that had a wetsuit swim and the air temperature was greater than 20 degrees. This will return a matchup for only these specific conditions for the group of athletes chosen. Filters are constructed as described in the [filters section](http://statistics.triathlon.org/v1.0/docs/statistics-api-overview#filters) and multiple filters [should be combined in a pipe delimited list](http://statistics.triathlon.org/v1.0/docs/statistics-api-overview#filters) e.g. for the preceding example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"filters=event.name,contains,Hamburg|program.wetsuit,eq,true|temperature.air,gte,20\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nAgain, you may pass in as many athletes into this analysis as you desire. For example the following query lists the Alistair Brownlee vs Javier Gomez Noya vs Jonathan Brownlee matchup for events that occurred in Hamburg.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl --header \\\"apikey: [[app:key]]\\\" \\\"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya,Jonathan%20Brownlee&filters=event.name,contains,Hamburg\\\"\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"matchups","type":"endpoint","title":"Matchups"}

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Query Params

athletes:
required
string
A single filter to determine the athletes to analyse
filters:
string
A list of filters to narrow down the events used in an analysis request based on event property values

Documentation

The Matchups endpoint allows you to determine the relative **head-to-head** results for a group of athletes. The required athletes parameter should contain a filter to determine a list of athletes for analysis. You may use any of the available [athlete properties](http://statistics.triathlon.org/v1.0/docs/results) to create your athlete grouping (i.e. athlete.id, athlete.name, athlete.first, athlete.last). So long as the athlete filter resolves to a set of athletes any filter is acceptable. For example to get a head-to-head matchup of Javier Gomez Noya and Alistair Brownlee we could make the following query: [block:code] { "codes": [ { "code": "curl --header \"apikey: [[app:key]]\" \"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya\"", "language": "curl" } ] } [/block] Alternatively using the athlete.id property: [block:code] { "codes": [ { "code": "curl --header \"apikey: [[app:key]]\" \"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.id,in,7788,5695\"", "language": "curl" } ] } [/block] The API call will return an object with a **total_matchups** property which is the number of times that these athletes have raced in the same events matching the chosen criteria (see [additional filters ](http://statistics.triathlon.org/v1.0/docs/matchups#using-filters) section). In addition the resulting athletes array lists all athletes used in the analysis together with the number of wins, losses and no-results for the matching events. [block:callout] { "type": "warning", "title": "Wins vs Losses vs No Results", "body": "As we are considering matchups a '*win*' is finishing ahead of all other athletes in the group (and not necessarily a race win). A *no result* can only occur when all athletes in the group do not complete, or are disqualified from the event. The Matchup endpoint is specifically for relative performance to a group and if you require absolute analysis types (such as number of race wins) you should use the primary [Results endpoint](http://statistics.triathlon.org/v1.0/docs/results)." } [/block] *The following example only shows a single result in the matchup_results array for brevity. The actual response would contain all 27 results.* [block:code] { "codes": [ { "code": "{\n \"code\":200,\n \"status\":\"success\",\n \"data\":{\n \"total_matchups\":27,\n \"athletes\":[\n {\n \"wins\":7,\n \"losses\":20,\n \"no_results\":0,\n \"athlete_id\":5695,\n \"athlete_title\":\"Javier Gomez Noya\",\n \"athlete_first\":\"Javier\",\n \"athlete_last\":\"Gomez Noya\",\n \"athlete_gender\":\"male\",\n \"athlete_age\":32,\n \"athlete_country\":\"ESP\",\n \"athlete_flag\":\"https:\\/\\/f9ca11ef49c28681fc01-0acbf57e00c47a50e70a1acb89e86c89.ssl.cf1.rackcdn.com\\/images\\/icons\\/es.png\",\n \"athlete_profile_image\":\"http:\\/\\/www.triathlon.org\\/images\\/athlete_thumbs\\/Gomez.png\",\n \"wts_ranking\":1,\n \"wts_starts\":44,\n \"wts_wins\":11,\n \"wts_podiums\":32,\n \"matchup_results\":[\n {\n \"format\":\"Standard\",\n \"finish_time\":6738,\n \"program.id\":4538,\n \"event.name\":\"2009 Dextro Energy Triathlon - ITU World Championship Series Madrid\",\n \"date\":\"2009-05-31T14:14:00+0000\",\n \"position\":3\n },\n //...... other results ......//\n ]\n },\n {\n \"wins\":20,\n \"losses\":7,\n \"no_results\":0,\n \"athlete_id\":7788,\n \"athlete_title\":\"Alistair Brownlee\",\n \"athlete_first\":\"Alistair\",\n \"athlete_last\":\"Brownlee\",\n \"athlete_gender\":\"male\",\n \"athlete_age\":27,\n \"athlete_country\":\"GBR\",\n \"athlete_flag\":\"https:\\/\\/f9ca11ef49c28681fc01-0acbf57e00c47a50e70a1acb89e86c89.ssl.cf1.rackcdn.com\\/images\\/icons\\/gb.png\",\n \"athlete_profile_image\":\"http:\\/\\/www.triathlon.org\\/images\\/athlete_thumbs\\/Brownlee.png\",\n \"wts_ranking\":5,\n \"wts_starts\":29,\n \"wts_wins\":19,\n \"wts_podiums\":23,\n \"matchup_results\":[\n {\n \"format\":\"Standard\",\n \"finish_time\":6686,\n \"program.id\":4538,\n \"event.name\":\"2009 Dextro Energy Triathlon - ITU World Championship Series Madrid\",\n \"date\":\"2009-05-31T14:14:00+0000\",\n \"position\":1\n },\n //...... other results ......//\n\t ]\n }\n ]\n }\n}", "language": "json", "name": null } ] } [/block] You are not limited to analysing two athletes and a group may be conceivably as large as you wish. The following example adds Jonathan Brownlee to the previous query. This will return all results where all three athletes have raced and determine the winner of each event as the first finisher of the three. [block:code] { "codes": [ { "code": "curl --header \"apikey: [[app:key]]\" \"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya,Jonathan%20Brownlee\"", "language": "curl" } ] } [/block] If you enter a query where no matchups have occurred, such as where a group of athletes have never raced each other, you will be returned a 400 response as per the following example: [block:code] { "codes": [ { "code": "{\n \"code\":400,\n \"status\":\"fail\",\n \"data\":{\n \"error\":\"This matchup has not occurred\"\n }\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Additional Filters" } [/block] Whilst analyzing all results for an athlete grouping is an excellent starting point, sometimes you may wish to delve deeper into the analysis e.g. what is the matchup over a specific course? How does a matchup vary over format (Sprint vs. Standard)? How does wearing a wetsuit affect the matchup? For this type of analysis we have the entire [filter property](http://statistics.triathlon.org/#filters) at our disposal and we can combine as complex a filter as we wish, for example events in Hamburg that had a wetsuit swim and the air temperature was greater than 20 degrees. This will return a matchup for only these specific conditions for the group of athletes chosen. Filters are constructed as described in the [filters section](http://statistics.triathlon.org/v1.0/docs/statistics-api-overview#filters) and multiple filters [should be combined in a pipe delimited list](http://statistics.triathlon.org/v1.0/docs/statistics-api-overview#filters) e.g. for the preceding example: [block:code] { "codes": [ { "code": "filters=event.name,contains,Hamburg|program.wetsuit,eq,true|temperature.air,gte,20", "language": "text" } ] } [/block] Again, you may pass in as many athletes into this analysis as you desire. For example the following query lists the Alistair Brownlee vs Javier Gomez Noya vs Jonathan Brownlee matchup for events that occurred in Hamburg. [block:code] { "codes": [ { "code": "curl --header \"apikey: [[app:key]]\" \"https://api.triathlon.org/v1/statistics/matchups?athletes=athlete.name,in,Alistair%20Brownlee,Javier%20Gomez%20Noya,Jonathan%20Brownlee&filters=event.name,contains,Hamburg\"", "language": "curl" } ] } [/block]

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}