Access symbol to get the real time price of token

PHOTO EMBED

Tue Mar 22 2022 09:28:44 GMT+0000 (UTC)

Saved by @Taylor #python #get #requests

import json
import os
import requests
from models import Asset

apikey = os.environ.get('API_KEY')

headers = {
    'X-CMC_PRO_API_KEY': apikey,
    'Accepts': 'application/json'
}

params = {
    'start': '1',
    'limit': '5',
    'convert': 'USD'
}


def getTokePrice(symbol):
    url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'

    json = requests.get(url, params=params, headers=headers).json()
    coins = json['data']
content_copyCOPY