Skip to content

Find opponents for a player

Match suggestions help a player find a fair game: opponents with a similar rating who are free at the same time. The API ranks them by how close their rating is, and every suggestion shares at least one weekly time window with the player.

This guide finds opponents for Ola K. (plr_2b7xq9mhk4), rated 1432, who is free on Tuesday evenings and Saturday mornings.

  1. Get the suggestions for the player. max_rating_gap sets how far an opponent’s rating can be from the player’s, in either direction:

    Terminal window
    curl --silent "$KRK_API_URL/players/plr_2b7xq9mhk4/match-suggestions?max_rating_gap=150&limit=5" \
    --header "X-API-Key: $KRK_API_KEY"

    The response suggests two opponents, closest rating first. The JavaScript and Python examples print:

    Marta Z.: gap 50, tuesday 19:00-21:00
    Kasia W.: gap 67, saturday 10:00-13:00

    Tomek B. isn’t suggested. The rating gap is within 150, but Tomek is only free on Thursdays, which don’t overlap with Ola’s windows.

  2. Read each suggestion to plan the match:

    • rating_gap: the difference between the two ratings. A smaller gap means a closer match.
    • overlapping_availability: the weekly time windows when both players are free, in Kraków local time (Europe/Warsaw). Propose a match inside one of them.
    • shared_venue_ids: venues both players prefer. It can be empty. Both suggestions here share Riverside Courts Podgórze (ven_7hk2p9wq4m).

    You have an opponent, a day and time, and a venue to propose.

  3. To suggest only opponents who play at a specific venue, add venue_id:

    Terminal window
    curl --silent "$KRK_API_URL/players/plr_2b7xq9mhk4/match-suggestions?venue_id=ven_7hk2p9wq4m" \
    --header "X-API-Key: $KRK_API_KEY"

    The response lists only opponents who prefer Riverside Courts Podgórze. Both Marta Z. and Kasia W. do, so the result is the same as in step 1.

An empty data array means no player fits both the rating gap and the availability. Try one of these:

  • Raise max_rating_gap, up to 500. The default is 150.
  • Remove venue_id, if you set it.
  • Ask the player to add more availability windows to their profile.

© 2026 Saverio Cirillo · KRKplaysTennis is a fictional API · Built with Starlight