title: Python: Can I put multiple variables into a URL for an API to a database?
body: <p>I'm trying to use Python to access a database via an API. The first part of my code works just fine. So this Python snippet...</p>
  
  <pre><code>import requests
  import json
  
  url = 'http://api.sportradar.us/ncaafb-p1/2016/REG/schedule.json?
  api_key=5tpxxxxxxxxxxxxxxxxx'
  
  response = requests.get(url)
  json_data = response.json()
  
  for games in json_data['weeks'][0]['games']:
      id = games.get('id')
      hid = games.get('home')
      vid = games.get('away')
      print("hometeam ",hid, " visitor ",vid, " game id ",id)
  </code></pre>
  
  <p>...produces this output:</p>
  
  <pre><code>hometeam  CAL  visitor  HAW  game id  1c4ee96d-3f08-43e1-8357-3bc2ee8bcaf8
  hometeam  NDS  visitor  CCH  game id  6f5121d1-d813-4ba3-bdf3-badf6412fa4f
  hometeam  WAG  visitor  SAC  game id  9a39c485-9930-4f70-8a16-59d9bc5e7822
  hometeam  MIZST  visitor  SWC  game id  196a7570-18d9-41ae-baa6-57ad9a3abce0
  .......
  </code></pre>
  
  <p>What I'm trying to do now is take the variables 'hid' and 'vid' and insert them as variables into a second url and make another call to the database. </p>
  
  <pre><code>curl = '"http://api.sportradar.us/ncaafb-p1/2016/REG/1/{the vid variable}/{the hid variable}/boxscore.json?api_key=5tpxxxxxxxxxxxxxxxxx"
  cresponse = requests.get(curl)
  x = cresponse.json()
  print(x)
  </code></pre>
  
  <p>Is this just a syntax issue? I tried to do it this way...</p>
  
  <pre><code>curl = '"http://api.sportradar.us/ncaafb-p1/2016/REG/1/{s}/{s}/boxscore.json?api_key=5tpxxxxxxxxxxxxxxxxx".format(vid, hid)'
  </code></pre>
  
  <p>and I've tried this:</p>
  
  <pre><code>curl = '"http://api.sportradar.us/ncaafb-p1/2016/REG/1/%s/%s/boxscore.json?api_key=5tpxxxxxxxxxxxxxxxxx"%(vid, hid)'
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>curl = '"http://api.sportradar.us/ncaafb-p1/2016/REG/1/%s/%s/boxscore.json?s=%s.ns&amp;vid=%s&amp;hid=%sapi_key=5tpxxxxxxxxxxxxxxxxx"%(ticker, vid, hid)
  </code></pre>
  
  <p>But I'm still getting various error messages. Any thoughts on how to do this correctly (given that 'hid' and 'vid' are multi-letter combinations like CAL and HAW)?</p>