title: Use API JSON to display a URL for an HTML Page
body: <p>I am completely new to all of this so please forgive any issues with how I'm describing and name things.  I have an HTML page where the user enters a portion of a URL string in order to launch a new window with the complete URL string.  I'd rather just lookup the portion of the URL using an API to create a JSON file and find it automatically.  Any ideas how I can accomplish this without user intervention?</p>
  <p>HTML (contains text box and button to launch a new window, which I would like to bypass this altogether)</p>
  <pre><code>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
   &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
   &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
   &lt;head&gt;
       &lt;title&gt;Cast Challonge&lt;/title&gt;
   &lt;script type=&quot;text/javascript&quot; src=&quot;https://code.jquery.com/jquery-3.6.0.js&quot;&gt;&lt;/script&gt;
  
   &lt;script type=&quot;text/javascript&quot;&gt;
  
   $(document).ready(function(){
  
       $('#button').click(function(e) {  
           var inputvalue = $(&quot;#input&quot;).val();
           window.open((&quot;http://challonge.com/&quot;+inputvalue+&quot;/module?theme=5928&amp;selected-round- 
  filter=2&amp;show_final_results=0&amp;multiplier=2&amp;show_tournament_name=1&amp;scale_to_fit=1&quot;),&quot;Tournament 
   Display&quot;,&quot;width=1280,height=720,resizable=no, toolbar=no, scrollbars=no, menubar=no, status=no, 
   directories=no&quot;);
  
       });
   });
   &lt;/script&gt; 
   &lt;/head&gt;
   &lt;body&gt;
  
          &lt;input type=&quot;text&quot; value=&quot;&quot; id=&quot;input&quot;&gt; 
          &lt;button type=&quot;button&quot; id=&quot;button&quot;&gt;Submit Tournament ID&lt;/button&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  <p>My sample API call is as follows:</p>
  <pre><code>[
    {
      &quot;tournament&quot;: {
        &quot;id&quot;: 9838153,
        &quot;name&quot;: &quot;2021/05/22 Saturday Night 8-Ball&quot;,
        &quot;url&quot;: &quot;BnkSat0522&quot;,
        &quot;description&quot;: &quot;&quot;,
        &quot;tournament_type&quot;: &quot;double elimination&quot;,
        &quot;started_at&quot;: &quot;2021-05-23T07:01:41.429+07:00&quot;,
        &quot;completed_at&quot;: &quot;2021-05-23T12:54:30.331+07:00&quot;,
        &quot;require_score_agreement&quot;: false,
        &quot;notify_users_when_matches_open&quot;: true,
        &quot;created_at&quot;: &quot;2021-05-23T03:41:49.015+07:00&quot;,
        &quot;updated_at&quot;: &quot;2021-05-23T12:54:30.580+07:00&quot;,
        &quot;state&quot;: &quot;complete&quot;,
        &quot;open_signup&quot;: false,
        &quot;notify_users_when_the_tournament_ends&quot;: true,
        &quot;progress_meter&quot;: 100,
        &quot;quick_advance&quot;: false,
        &quot;hold_third_place_match&quot;: false,
        &quot;pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;pts_for_bye&quot;: &quot;1.0&quot;,
        &quot;swiss_rounds&quot;: 0,
        &quot;private&quot;: false,
        &quot;ranked_by&quot;: &quot;match wins&quot;,
        &quot;show_rounds&quot;: true,
        &quot;hide_forum&quot;: false,
        &quot;sequential_pairings&quot;: false,
        &quot;accept_attachments&quot;: false,
        &quot;rr_pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;rr_pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;created_by_api&quot;: false,
        &quot;credit_capped&quot;: false,
        &quot;category&quot;: null,
        &quot;hide_seeds&quot;: false,
        &quot;prediction_method&quot;: 0,
        &quot;predictions_opened_at&quot;: null,
        &quot;anonymous_voting&quot;: false,
        &quot;max_predictions_per_user&quot;: 1,
        &quot;signup_cap&quot;: null,
        &quot;game_id&quot;: 773,
        &quot;participants_count&quot;: 24,
        &quot;group_stages_enabled&quot;: false,
        &quot;allow_participant_match_reporting&quot;: false,
        &quot;teams&quot;: false,
        &quot;check_in_duration&quot;: null,
        &quot;start_at&quot;: null,
        &quot;started_checking_in_at&quot;: null,
        &quot;tie_breaks&quot;: [
          &quot;match wins vs tied&quot;,
          &quot;game wins&quot;,
          &quot;points scored&quot;
        ],
        &quot;locked_at&quot;: null,
        &quot;event_id&quot;: null,
        &quot;public_predictions_before_start_time&quot;: false,
        &quot;ranked&quot;: false,
        &quot;grand_finals_modifier&quot;: null,
        &quot;predict_the_losers_bracket&quot;: false,
        &quot;spam&quot;: null,
        &quot;ham&quot;: null,
        &quot;rr_iterations&quot;: 1,
        &quot;tournament_registration_id&quot;: null,
        &quot;donation_contest_enabled&quot;: null,
        &quot;mandatory_donation&quot;: null,
        &quot;non_elimination_tournament_data&quot;: {
          &quot;participants_per_match&quot;: &quot;&quot;
        },
        &quot;auto_assign_stations&quot;: null,
        &quot;only_start_matches_with_stations&quot;: null,
        &quot;registration_fee&quot;: &quot;0.0&quot;,
        &quot;registration_type&quot;: &quot;free&quot;,
        &quot;split_participants&quot;: false,
        &quot;allowed_regions&quot;: [
          
        ],
        &quot;show_participant_country&quot;: null,
        &quot;program_id&quot;: null,
        &quot;program_classification_ids_allowed&quot;: null,
        &quot;team_size_range&quot;: null,
        &quot;toxic&quot;: null,
        &quot;description_source&quot;: &quot;&quot;,
        &quot;subdomain&quot;: null,
        &quot;full_challonge_url&quot;: &quot;https://challonge.com/BnkSat0522&quot;,
        &quot;live_image_url&quot;: &quot;https://challonge.com/BnkSat0522.svg&quot;,
        &quot;sign_up_url&quot;: null,
        &quot;review_before_finalizing&quot;: true,
        &quot;accepting_predictions&quot;: false,
        &quot;participants_locked&quot;: true,
        &quot;game_name&quot;: &quot;8-ball&quot;,
        &quot;participants_swappable&quot;: false,
        &quot;team_convertable&quot;: false,
        &quot;group_stages_were_started&quot;: false
      }
    },
    {
      &quot;tournament&quot;: {
        &quot;id&quot;: 9845539,
        &quot;name&quot;: &quot;2021/05/24 Monday Night 10-Ball&quot;,
        &quot;url&quot;: &quot;20210524&quot;,
        &quot;description&quot;: &quot;&quot;,
        &quot;tournament_type&quot;: &quot;double elimination&quot;,
        &quot;started_at&quot;: &quot;2021-05-25T06:34:46.053+07:00&quot;,
        &quot;completed_at&quot;: &quot;2021-05-25T10:54:03.406+07:00&quot;,
        &quot;require_score_agreement&quot;: false,
        &quot;notify_users_when_matches_open&quot;: true,
        &quot;created_at&quot;: &quot;2021-05-25T04:01:56.922+07:00&quot;,
        &quot;updated_at&quot;: &quot;2021-05-25T10:54:03.589+07:00&quot;,
        &quot;state&quot;: &quot;complete&quot;,
        &quot;open_signup&quot;: false,
        &quot;notify_users_when_the_tournament_ends&quot;: true,
        &quot;progress_meter&quot;: 100,
        &quot;quick_advance&quot;: false,
        &quot;hold_third_place_match&quot;: false,
        &quot;pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;pts_for_bye&quot;: &quot;1.0&quot;,
        &quot;swiss_rounds&quot;: 0,
        &quot;private&quot;: false,
        &quot;ranked_by&quot;: &quot;match wins&quot;,
        &quot;show_rounds&quot;: true,
        &quot;hide_forum&quot;: false,
        &quot;sequential_pairings&quot;: false,
        &quot;accept_attachments&quot;: false,
        &quot;rr_pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;rr_pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;created_by_api&quot;: false,
        &quot;credit_capped&quot;: false,
        &quot;category&quot;: null,
        &quot;hide_seeds&quot;: false,
        &quot;prediction_method&quot;: 0,
        &quot;predictions_opened_at&quot;: null,
        &quot;anonymous_voting&quot;: false,
        &quot;max_predictions_per_user&quot;: 1,
        &quot;signup_cap&quot;: null,
        &quot;game_id&quot;: 6341,
        &quot;participants_count&quot;: 22,
        &quot;group_stages_enabled&quot;: false,
        &quot;allow_participant_match_reporting&quot;: true,
        &quot;teams&quot;: false,
        &quot;check_in_duration&quot;: null,
        &quot;start_at&quot;: null,
        &quot;started_checking_in_at&quot;: null,
        &quot;tie_breaks&quot;: [
          &quot;match wins vs tied&quot;,
          &quot;game wins&quot;,
          &quot;points scored&quot;
        ],
        &quot;locked_at&quot;: null,
        &quot;event_id&quot;: null,
        &quot;public_predictions_before_start_time&quot;: false,
        &quot;ranked&quot;: false,
        &quot;grand_finals_modifier&quot;: null,
        &quot;predict_the_losers_bracket&quot;: false,
        &quot;spam&quot;: null,
        &quot;ham&quot;: null,
        &quot;rr_iterations&quot;: 1,
        &quot;tournament_registration_id&quot;: null,
        &quot;donation_contest_enabled&quot;: null,
        &quot;mandatory_donation&quot;: null,
        &quot;non_elimination_tournament_data&quot;: {
          &quot;participants_per_match&quot;: &quot;&quot;
        },
        &quot;auto_assign_stations&quot;: false,
        &quot;only_start_matches_with_stations&quot;: false,
        &quot;registration_fee&quot;: &quot;0.0&quot;,
        &quot;registration_type&quot;: &quot;free&quot;,
        &quot;split_participants&quot;: false,
        &quot;allowed_regions&quot;: [
          
        ],
        &quot;show_participant_country&quot;: null,
        &quot;program_id&quot;: null,
        &quot;program_classification_ids_allowed&quot;: null,
        &quot;team_size_range&quot;: null,
        &quot;toxic&quot;: null,
        &quot;description_source&quot;: &quot;&quot;,
        &quot;subdomain&quot;: null,
        &quot;full_challonge_url&quot;: &quot;https://challonge.com/20210524&quot;,
        &quot;live_image_url&quot;: &quot;https://challonge.com/20210524.svg&quot;,
        &quot;sign_up_url&quot;: null,
        &quot;review_before_finalizing&quot;: true,
        &quot;accepting_predictions&quot;: false,
        &quot;participants_locked&quot;: true,
        &quot;game_name&quot;: &quot;10-Ball&quot;,
        &quot;participants_swappable&quot;: false,
        &quot;team_convertable&quot;: false,
        &quot;group_stages_were_started&quot;: false
      }
    },
    {
      &quot;tournament&quot;: {
        &quot;id&quot;: 9851001,
        &quot;name&quot;: &quot;2021/05/26 Wednesday Night 9-Ball&quot;,
        &quot;url&quot;: &quot;20210526&quot;,
        &quot;description&quot;: &quot;&quot;,
        &quot;tournament_type&quot;: &quot;double elimination&quot;,
        &quot;started_at&quot;: &quot;2021-05-26T20:48:53.085+07:00&quot;,
        &quot;completed_at&quot;: null,
        &quot;require_score_agreement&quot;: false,
        &quot;notify_users_when_matches_open&quot;: true,
        &quot;created_at&quot;: &quot;2021-05-26T20:46:47.342+07:00&quot;,
        &quot;updated_at&quot;: &quot;2021-05-26T20:48:53.158+07:00&quot;,
        &quot;state&quot;: &quot;underway&quot;,
        &quot;open_signup&quot;: false,
        &quot;notify_users_when_the_tournament_ends&quot;: true,
        &quot;progress_meter&quot;: 0,
        &quot;quick_advance&quot;: false,
        &quot;hold_third_place_match&quot;: false,
        &quot;pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;pts_for_bye&quot;: &quot;1.0&quot;,
        &quot;swiss_rounds&quot;: 0,
        &quot;private&quot;: false,
        &quot;ranked_by&quot;: &quot;match wins&quot;,
        &quot;show_rounds&quot;: true,
        &quot;hide_forum&quot;: true,
        &quot;sequential_pairings&quot;: false,
        &quot;accept_attachments&quot;: false,
        &quot;rr_pts_for_game_win&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_game_tie&quot;: &quot;0.0&quot;,
        &quot;rr_pts_for_match_win&quot;: &quot;1.0&quot;,
        &quot;rr_pts_for_match_tie&quot;: &quot;0.5&quot;,
        &quot;created_by_api&quot;: false,
        &quot;credit_capped&quot;: false,
        &quot;category&quot;: null,
        &quot;hide_seeds&quot;: false,
        &quot;prediction_method&quot;: 0,
        &quot;predictions_opened_at&quot;: null,
        &quot;anonymous_voting&quot;: false,
        &quot;max_predictions_per_user&quot;: 1,
        &quot;signup_cap&quot;: null,
        &quot;game_id&quot;: 485,
        &quot;participants_count&quot;: 2,
        &quot;group_stages_enabled&quot;: false,
        &quot;allow_participant_match_reporting&quot;: false,
        &quot;teams&quot;: false,
        &quot;check_in_duration&quot;: null,
        &quot;start_at&quot;: null,
        &quot;started_checking_in_at&quot;: null,
        &quot;tie_breaks&quot;: [
          &quot;match wins vs tied&quot;,
          &quot;game wins&quot;,
          &quot;points scored&quot;
        ],
        &quot;locked_at&quot;: null,
        &quot;event_id&quot;: null,
        &quot;public_predictions_before_start_time&quot;: false,
        &quot;ranked&quot;: false,
        &quot;grand_finals_modifier&quot;: null,
        &quot;predict_the_losers_bracket&quot;: false,
        &quot;spam&quot;: null,
        &quot;ham&quot;: null,
        &quot;rr_iterations&quot;: 1,
        &quot;tournament_registration_id&quot;: null,
        &quot;donation_contest_enabled&quot;: null,
        &quot;mandatory_donation&quot;: null,
        &quot;non_elimination_tournament_data&quot;: {
          &quot;participants_per_match&quot;: &quot;&quot;
        },
        &quot;auto_assign_stations&quot;: null,
        &quot;only_start_matches_with_stations&quot;: null,
        &quot;registration_fee&quot;: &quot;0.0&quot;,
        &quot;registration_type&quot;: &quot;free&quot;,
        &quot;split_participants&quot;: false,
        &quot;allowed_regions&quot;: [
          
        ],
        &quot;show_participant_country&quot;: null,
        &quot;program_id&quot;: null,
        &quot;program_classification_ids_allowed&quot;: null,
        &quot;team_size_range&quot;: null,
        &quot;toxic&quot;: null,
        &quot;description_source&quot;: &quot;&quot;,
        &quot;subdomain&quot;: null,
        &quot;full_challonge_url&quot;: &quot;https://challonge.com/20210526&quot;,
        &quot;live_image_url&quot;: &quot;https://challonge.com/20210526.svg&quot;,
        &quot;sign_up_url&quot;: null,
        &quot;review_before_finalizing&quot;: true,
        &quot;accepting_predictions&quot;: false,
        &quot;participants_locked&quot;: true,
        &quot;game_name&quot;: &quot;9-ball&quot;,
        &quot;participants_swappable&quot;: false,
        &quot;team_convertable&quot;: false,
        &quot;group_stages_were_started&quot;: false
      }
    }
  ]
  </code></pre>
  <p>Where I am trying to grab a tournament that the state is &quot;underway&quot; and return &quot;url&quot; that can then be used to launch a complete URL as described above.</p>
  <p>I've created the following:</p>
  <pre><code>&lt;?php
   $apikey = 'MyAPIKEY';
   $contents_api = fopen(&quot;https://api.challonge.com/v1/tournaments.json? 
  state=all&amp;api_key=$apikey&quot;, &quot;r&quot;);
   $json = stream_get_contents($contents_api);
   $jsonData = json_decode($json, TRUE);
   print $jsonData[count($jsonData)-1]['tournament']['url'];
   ?&gt;
  </code></pre>
  <p>Now I need to figure out how to grab this information and load the page!!!!</p>
  <p>Again, I know this is probably not the best way to ask however, any guidance pointing me in the correct direction would be very helpful.</p>