import requests
import json


def get_tipranks_stocks(score):
    """
    get stocks based on tipranks score
    :param score: from 1 to 5 (probably maps to 1-10 on the tipranks website)
    :return: list of 20 stocks from tipranks with requested score
    """

    url = f'https://www.tipranks.com/api/Screener/GetStocks/?tipranksScore={score}'
    x = requests.get(url)
    y = json.loads(x.text)

    symbols = []
    for i in range(20):
        symbols.append(y['data'][i]['ticker'])

    return symbols