# CoinMarketCap API Price Notifier - Error

**URL:** <https://discuss.python.org/t/coinmarketcap-api-price-notifier-error/54475>\
**Category:** Python Help\
**Tags:** help\
**Created:** [May 28, 2024, 8:20pm UTC](https://discuss.python.org/t/coinmarketcap-api-price-notifier-error/54475 "2024-05-28T20:20:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sookello](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/sookello/32/20148_2.png) [@sookello](https://discuss.python.org/u/sookello)\
**Post date:** [May 28, 2024, 8:20pm UTC](https://discuss.python.org/t/coinmarketcap-api-price-notifier-error/54475/1 "2024-05-28T20:20:32Z")

</div>

```import
import requests
from datetime import datetime

currency = 'KES'

global_url = 'https://api.coinmarketcap.com/v1/global/?convert=' + currency

request = requests.get(global_url)
results = request.json()

# print(json.dumps(results, sort_keys=True, indent=4))

active_currencies = results['data']['active_cryptocurrencies']
activate_markets = results['data']['active_markets']
bitcoin_percentage = results['data']['bitcoin_percentage_of_market_cap']
last_updated = results['data']['last_updated']
global_cap = int(results['data']['quotes'][currency]['total_market_cap'])
global_volume = int(results['data']['quotes'][currency]['total_volume_24h'])

active_currencies_string = '{:,}'. format(active_currencies)
active_markets_string = '{:,}'. format(activate_markets)
global_cap_string = '{:,}'. format(global_cap)
global_volume_string = '{:,}'. format(global_volume)

last_updated_string = datetime.fromtimestamp(
    last_updated).strftime('%B %d, %Y at %I:%M%p')

print()
print('There are currently' + active_currencies_string +
      'active cryptocurrencies and ' + active_markets_string + 'activate markets.')
print('The global cap of all cryptos is ' + global_cap_string +
      'and 24h global volume is' + global_volume_string + ',')
print('Bitcon\'s total percentage of the global cap is' +
      str(bitcoin_percentage) + '%')
print()
print('This information was updated on' + last_updated_string + '.')

```

#Python Help Error that appears after running the codes

```python
$ python coincap_global.py
Traceback (most recent call last):
  File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\json\ __init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\admin\desktop\capstone_project\coincap_global.py", line 10, in <module>
    results = request.json()
              ^^^^^^^^^^^^^^
  File "C:\Users\admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

admin@DESKTOP-T65F711 MINGW64 ~/desktop/capstone_project

```

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [May 28, 2024, 9:01pm UTC](https://discuss.python.org/t/coinmarketcap-api-price-notifier-error/54475/2 "2024-05-28T21:01:19Z")

</div>

Please [read the pinned thread](https://discuss.python.org/t/about-the-python-help-category/42) and format the code properly (and use the same formatting for the error message); and please try to explain a little bit about what you are trying to do and what you want to know.

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [May 28, 2024, 11:07pm UTC](https://discuss.python.org/t/coinmarketcap-api-price-notifier-error/54475/3 "2024-05-28T23:07:01Z")

</div>

You’re expecting that the request always returns JSON data, but, clearly, it doesn’t.

Try printing the value of `request.text` to see what it’s actually returning.
