ESPN Medals Data
Medals
Code for the gold
-
The ESPN Medals API allows you to interact with medal and event result information from the Summer and Winter Olympic Games.
This API is currently a version 1 (/v1/) release.
Availability Public Partner Premium Partner ESPN -
The ESPN Medals API accepts a GET request.
Users can retrieve medal results for a particular Olympic Games (Winter or Summer) ranked by country, for a specific country, or for a specific athlete.
The format of an API request is as follows:
http://api.espn.com/:version/:resource/:method?apikey=:yourkeySample Medals Requests
Action URI Description GET http://api.espn.com/v1/sports/olympics/medals Get medal counts by country for the most recent Olympic Games, ranked by total medals won. GET http://api.espn.com/v1/sports/olympics/countries/usa/medals Get medal count for the most recent Olympic Games for the USA. GET http://api.espn.com/v1/sports/olympics/countries/usa/medals?enable=competitions Get medal count for the most recent Olympic Games for the USA, with competition details including individual winners and winning score. GET http://api.espn.com/v1/sports/olympics/medals?dates=2008&season=summer Get medal counts by country for the 2008 Summer Olympics, ranked by total medals won. GET http://api.espn.com/v1/sports/olympics/alpine-skiing/medals?dates=2010&season=winter Get medal counts by country for the 2010 Winter Olympics for alpine skiing competitions. GET http://api.espn.com/v1/sports/olympics/athletes/52386/medals?dates=2008&season=summer Get medal performance for an individual athlete in the 2008 Summer Olympics. Helper API Calls
The following "helper" API calls may come in handy when working with the Medals API.
Action URI Description GET http://api.espn.com/v1/sports/olympics/countries Returns an array of countries (including ID, abbreviation, and name) that can be used with the Medals API. GET http://api.espn.com/v1/sports/olympics Returns an array of sports (including olympic sport ID and name) for the current Olympic Games that can be used with the Medals API. GET http://api.espn.com/v1/sports/olympics?season=winter&dates=2010 Returns an array of sports (including olympic sport ID and name) for a specific Olympic Games that can be used with the Medals API. -
Quick Navigation
Resources
Back to topResource Name Description
Availabilitypublic partner premium
partnerespn /sports/olympics Medals for the Olympic Games. Methods
Back to topURI Parameters
In addition to the standard URI parameters, the ESPN Headlines API also supports the following URI parameters:
-
Quick Navigation
Returned Data
Requests to the ESPN Medals API return the following data:
Back to topThe following table outlines the data that is returned when the 'competitions' option is enabled. The 'competitions' array appears within the medals.gold, medals.silver, or medals.bronze objects as appropriate.
Back to topSample Response
Back to topXMLThe following XML output was rendered with an internal key calling:
http://api.espn.com/v1/sports/olympics/countries/cro/medals?season=summer&dates=2008&enable=competitions&_accept=text/xml&apikey=:yourkey.JSONThe following JSON output was rendered with an internal key calling:
http://api.espn.com/v1/sports/olympics/countries/cro/medals?season=summer&dates=2008&enable=competitions&apikey=:yourkey. -
Sample Code
JavaScript// Example JSONP request with jQuery $.ajax({ url: "http://api.espn.com/v1/sports/news/headlines", data: { // enter your developer api key here apikey: "{api key}", // the type of data you're expecting back from the api _accept: "application/json" }, dataType: "jsonp", success: function(data) { // create an unordered list of headlines var ul = $('<ul/>'); $.each(data.headlines, function() { var li = $('<li/>').text(this.headline); ul.append(li) }); // append this list to the document body $('body').append(ul); }, error: function() { // handle the error } });
