0

I am using API of riots game. I need to list all the champions and there matches and some other records related to it. This is the code I will get the $championInfo by sending first request to get all champions

    foreach($championsInfo as $key => $value){
    global $wpdb;
    $API_Booster_ID = $value['champion_id'];
    $API_Booster_Name = $value['champion_name'];
    $API_Booster_Image = '';
    $API_Summoner_ID = $value['summonerid'];
    Insert Query Here       


    /*Spells Loop*/     
    foreach($value['spells'] as $spellsKey => $spellsValue){

            $API_Spells_Name = $spellsValue['name'];
            $API_Spells_Key = $spellsValue['key'];
            $API_Spells_Image = $spellsValue['image']['full'];

            Inserte Query Here

        }


    foreach($value['matchlist']['matches'] as $matchesKey => $matchesValue){
            Need to send API Request based on match id (this will be more then 600 times for every $championInfo Loop)
            Insert Query Here

        }   

}

How to reduce the request of API? How should i get all the records in a single request of API or within a limited request?

  • Thank you for your kind reply. I don't want to use 600 API request. I have provided a demo code here in order to see the flow of data i want. In this code, we are using around 600 API request, but i don't want to use this much of request. I want to use limited request and need to get the whole data of every champion. – Chirag Patel May 09 '16 at 04:46
  • My concern is how to optimize this code in a limited API request.? – Chirag Patel May 09 '16 at 04:46
  • You can only improve your code when you change the API, but you can't, so you should take an other approach. Maybe you can get the last 10 or 20 matches and save them for the next visit? Is the same user visits again you take the next ones? – R Pelzer May 09 '16 at 07:25

0 Answers0