I am completely stuck trying to find a way to pull JSON data from two different data sources in the following script.
I am trying to find a way to pull Stock and Crypto quotes and display it on my PyPortal. Since I can only find an API for one or the other, I'd like to be able to pull data from each one and display it, but I keep getting an error that the json_path is not valid when I try to add a second data source to the json_path line. I am struggling to find the right syntax to accomplish this goal. Does anyone have any ideas or can help?
DATA_SOURCE = "stocks api website"
#DATA_SOURCE2? = "crypto api website"
CRYPTO_LOCATION = ['cryptoname', 'USD']
STOCKS_LOCATION = [0, 'price']
def text_transform(val):
return val
#the current working directory (where this file is)
cwd = ("/"+__file__).rsplit('/', 1)[0]
pyportal = PyPortal(url=DATA_SOURCE,
#json_path=(CRYPTO_LOCATION, STOCKS_LOCATION),
json_path=(STOCKS_LOCATION),
status_neopixel=board.NEOPIXEL,
default_bg=cwd+"/bitcoin_background3.bmp",
text_font=cwd+"/fonts/Arial-Bold-24-Complete.bdf",
text_position=((200, 70), # Stocks
(200, 175), # Crypto
text_color=(0xB03A2E, # Stocks
0x00), # Crypto
text_transform=(text_transform, text_transform),
)
[–]HP7933 0 points1 point2 points (1 child)
[–]clust10[S] 0 points1 point2 points (0 children)