Make your first request
In this quickstart, you start a local mock of the KRKplaysTennis API, list players, and read one player’s rating. It takes less than 5 minutes.
KRKplaysTennis is fictional, so there’s no live server. The mock is Prism: it reads the OpenAPI spec of the API and answers each request with the examples in it.
Before you begin
Section titled “Before you begin”- Node.js 22 or later. You need it to run the mock, and for the JavaScript examples.
- A macOS or Linux terminal. On Windows, use WSL.
- For the Python examples, Python 3.10 or later with the
requestspackage (pip install requests).
-
Start the mock:
Terminal window npx @stoplight/prism-cli@5 mock https://saverio-cirillo.com/krk-plays-tennis-api/openapi.yamlThe first run downloads Prism, which takes a few seconds. When the mock is ready, the last line of the output is:
Prism is listening on http://127.0.0.1:4010Keep this terminal open.
-
In a new terminal, set the base URL and an API key:
Terminal window export KRK_API_URL=http://127.0.0.1:4010export KRK_API_KEY=quickstart-keyThe mock accepts any API key, as long as you send one. Every example in these docs reads these two variables, so the same code works with the mock and with a real key.
To check the variables, run
echo $KRK_API_URL. The output ishttp://127.0.0.1:4010. -
List the players:
Terminal window curl --silent "$KRK_API_URL/players" \--header "X-API-Key: $KRK_API_KEY"Save this code as
list-players.mjs, then runnode list-players.mjs:const response = await fetch(`${process.env.KRK_API_URL}/players`, {headers: { 'X-API-Key': process.env.KRK_API_KEY },});if (!response.ok) throw new Error(`Request failed: ${response.status}`);console.log(JSON.stringify(await response.json(), null, 2));Save this code as
list_players.py, then runpython3 list_players.py:import jsonimport osimport requestsresponse = requests.get(f"{os.environ['KRK_API_URL']}/players",headers={"X-API-Key": os.environ["KRK_API_KEY"]},)response.raise_for_status()print(json.dumps(response.json(), indent=2))The response lists three players: Kasia W., Marta Z., and Ola K. Each player has a
ratingwith avalueand aconfidence.next_cursorisnull, because there are no more pages. The start of the response looks like this:{"data": [{"id": "plr_9fz3tr6wn1","display_name": "Kasia W.","self_assessed_ntrp": 4,"rating": { "value": 1499, "confidence": 70 }, -
Get the rating of Ola K., whose player ID is
plr_2b7xq9mhk4:Terminal window curl --silent "$KRK_API_URL/players/plr_2b7xq9mhk4/rating" \--header "X-API-Key: $KRK_API_KEY"Save this code as
get-rating.mjs, then runnode get-rating.mjs:const playerId = 'plr_2b7xq9mhk4';const response = await fetch(`${process.env.KRK_API_URL}/players/${playerId}/rating`, {headers: { 'X-API-Key': process.env.KRK_API_KEY },});if (!response.ok) throw new Error(`Request failed: ${response.status}`);console.log(JSON.stringify(await response.json(), null, 2));Save this code as
get_rating.py, then runpython3 get_rating.py:import jsonimport osimport requestsplayer_id = "plr_2b7xq9mhk4"response = requests.get(f"{os.environ['KRK_API_URL']}/players/{player_id}/rating",headers={"X-API-Key": os.environ["KRK_API_KEY"]},)response.raise_for_status()print(json.dumps(response.json(), indent=2))The response shows Ola’s rating after one rated match:
{"player_id": "plr_2b7xq9mhk4","value": 1432,"confidence": 30,"k_factor": 48,"rated_matches": 1,"last_rated_match_at": "2026-10-10T18:00:00+02:00","updated_at": "2026-10-10T20:43:12Z"}Ola started at 1400, from a self-assessed NTRP level of 3.5. Winning that first match raised the rating by 32 and the confidence from 20 to 30.
You’ve made your first two requests to the KRKplaysTennis API.
Next steps
Section titled “Next steps”- How ratings work: why Ola’s rating went from 1400 to 1432.
- Explain a rating change: reproduce that change from the API data.
- Find opponents for a player: suggest fair matches.
- Authenticate with an API key: how API keys work, and how to keep yours out of your code.
- API reference: the parameters and responses of every operation.
© 2026 Saverio Cirillo · KRKplaysTennis is a fictional API · Built with Starlight