title: Sporadic JSONDecodeError during API Request
body: <p>I am creating a simple program that takes the 'last' value from Bitstamp.net API and uses it. See code below. </p>
  
  <pre><code>def getBitcoinPrice():
  
      url = 'https://www.bitstamp.net/api/ticker/'
      try:
          r = requests.get(url)
          priceFloat = float(json.loads(r.text)['last'])
          return priceFloat
      except requests.ConnectionError:
          print("Error querying Bitstamp API")
          os.system('say "The program broke."')
  </code></pre>
  
  <p>I will get sporadic JSONDecodeError sometimes after 3 minutes, other times after several hours. I have looked everywhere and can't figure this out. See the error below. Any help is greatly appreciated!</p>
  
  <pre><code>File "/Users/paulkaraffa/PycharmProjects/socialbitanalytics/actionEvaluator.py", line 70, in &lt;module&gt;
      btcValues.append(getBitcoinPrice())
  
  File "/Users/paulkaraffa/PycharmProjects/socialbitanalytics/actionEvaluator.py", line 26, in getBitcoinPrice
      priceFloat = float(json.loads(r.text)['last'])
  
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
      return _default_decoder.decode(s)
  
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  </code></pre>