← Back to board

Head-to-head record on website

OpenmobikOOOmobikOOO6 messagesstarted Jul 11, 2026, 7:28 PM
websiteplanned
mobikOOOmobikOOOOP3 months ago
I want this so baddd🥺🥺🥺
16
tjthings
tjthings3 months ago
I want to see how much elo I have taken from snakezy
yahiamice.
yahiamice.2 months ago
I want to see how much elo I have given to tjthings
tjthings
tjthings2 months ago
thank you for your donation 🙏
Uniquepotatoes
Uniquepotatoes2 months ago
import sys
import requests

url = 'https://draftoutmc.com/api/stats/'
page = '?page='

def main():
    if len(sys.argv) - 1 != 2: 
        raise ValueError("Expected 2 arguments")
    if sys.argv[1] == sys.argv[2]:
        raise ValueError("Arguments must be unique")
    
    player1 = sys.argv[1]
    player2 = sys.argv[2]
    p1_res = requests.get(url + player1)
    p2_res = requests.get(url + player2)
    p1_data = p1_res.json()
    p2_data = p2_res.json()
    p1_pagecount = p1_data["totalPages"]

    p2_wins = 0
    h2h_matches = 0

    if not (p1_data["player"] and p2_data["player"]):
        raise ValueError("Both players must exist")
    
    total_matches_p1 = []
    total_matches_p1.extend(p1_data["matches"])

    for i in range(2, p1_pagecount + 1):
        p1_add_res = requests.get(url + player1 + page + str(i))
        p1_add_data = p1_add_res.json()
        total_matches_p1.extend(p1_add_data["matches"])

    for match in total_matches_p1: 
        for participant in match["participants"]:
            if participant["username"] == player2:
                h2h_matches += 1
                if participant["won"]:
                    p2_wins += 1
    
    print("Total matches played")
    print(h2h_matches)
    print(player1 + " wins")
    print(h2h_matches - p2_wins)
    print(player2 + " wins")
    print(p2_wins)

if __name__ == "__main__":
    main()
2
Uniquepotatoes
Uniquepotatoes2 months ago
here is a lil python script if someone wants to check this before they add it