Generates a graphic representation (an SVG file) of singles draws and results for top tier professional tennis tournaments using data from the Sportradar Tennis v3 API. Here are some examples of documents produced using this application. To convert SVG files to PDF I recommend Boxy SVG.
To use this application, you’ll first need to register an account with Sportradar and get a trial API key.
Download the code and install the packages upon which it depends:
npm install
Executing the code requires parameters as follows:
node index.js tournament_code year event_code stage_code api_key [show_timestamp]
Valid values for tournament_code
:
- ao — Australian Open
- iw — Indian Wells
- mi — Miami Open
- ma — Madrid
- ro — Rome
- rg — French Open
- wi — Wimbledon
- ca — Canadian Open
- ci — Cincinnati
- us — US Open
Valid values for event_code
:
- ms — Men’s Singles
- ws — Women’s Singles
Valid values for stage_code
:
- q — Qualifying
- m — Main Draw
Valid values for show_timestamp
:
- y — Include the current timestamp on the generated draw sheet (default)
- n — Do not include the current timestamp
If you are testing adjustments to the code, you can regenerate the SVG file without calling the API every time, because the parameters and API results are cached locally. To regenerate the SVG file from local cache, just execute without parameters:
node index.js
The code embeds Sportradar’s identifiers for recent tournaments. If you want to extend the code to include additional tournaments/events, you’ll need to add season identifiers to the code. In the Sportradar API, a competition is an event at a tournament, eg "Australian Open Women’s Singles", and a season is an individual occurrence of an event, eg "Australian Open Women’s Singles 2022". You can call the API endpoints Competitions and Competition Seasons to discover season identifiers.