Learning how to extract info giving from API to get more info Python, Riots API

92 views Asked by At

So I am learning python and learning how to use the riots api and everything is a first for me. What I am doing now is that I want to learn the information from a match using Riots API. With this code:

my_matches = watcher.match.matchlist_by_puuid(regional_routing_value,PUID)
last_match = my_matches[0]
match_detail = watcher.match.by_id(regional_routing_value,last_match)

It gets the information from the user's PUID extracts the matchID to give me the history of the match. When I use the developers websites it gives me the participants information:

        "participants": [
            "SQypter-G2j9l5fMjtqiEDGMvNOXh7-yVDfOHA_1_8x4EwdErILr_R-o5PFgZzdY_jGKtScWZBCX1w",
            "uIHQPg4YLe6buMjl2-kFJAlO9dWRsrRyI1hXVDCY3gGe_xS-3XjGnt19JCpvdqmCatzNQFgxDODcjQ",
            "vrg5ECZAtPNZfoNIyFH3j1bh7n_dpxZ1KXNTiWnDqVCYBMo9Pxm8fZ-MT7k64c8nkg-jbkLqB307hg",
            "XyIkANStBNoFxIj815EA8ttoDfDHBPjNsDnQrWExB6r5YsIm6a7t50U1_wwurfgF3Z7PmL2Lz0YjmQ",
            "BvGLtiPkWtSvQbzVKK63_ZM9SBfiad2eoo2W0VNux_doElBMCw4Q7qD-ojUgj9-85y0PyT2PqzAZvw",
            "w8zW_Y8185EDo-yIEUu_KuSXirwS3Pi9ApaT3NELPPd-9ANUjvqXP1mysUOF5T-7c5WBwl1pZKzGJA",
            "PlF6r04FQ-EVec4l24c3JvpLpIG-MPuQeeWg_Vf3SkCxltpYInIqBzlV5s4Zs7Utbb3rYlalLBA60g",
            "1jQPIYe_vnxxKzXq3Biyit_5-2oAACDXE1uG5hvvqvIt1nCBy40eF6bf9vUYnc54QTFKtghzX0-9cg",
            "AkuGrti57cUz2G1OfRBP0BYZEc-I-A3HugKN_hltfEyu9G1UK8OXg4lErIvSA3iLZA5CZ9FZFmsRDw",
            "5SY6oWFCaJxDfkIMC6JLK-xBgv57odk1bF33r-WwzqJDYdxggalmVzyBsKQBF_hVz5o_hzwfExdelA"
        ]

I would like to know how I am able to use this information to find their stuff like K/D/A, Items and etc I just know that I am using a dictionary but I really haven't found much that helped me so far. Any information is helpful cause in the end I am just trying to learn! Thank you so much

1

There are 1 answers

0
DarkIntaqt On

Actually there are some more information than just the participants

The JSON Structure is like this:

  • metadata
    • participants (that's where you are)
  • info
    • participants (stats like K/D/A and so on..)

So to get the data and loop over it you can do something like this:

for participantData in match_detail["info"]["participants"]:
   print(participantData)
   #KDA = participantData["kills] / participantData["deaths"] / participantData["assists]