This is a simple example of an advanced functionality of Valkyrie Engine, where you will learn how to pull data from the web and display it in your scene.
We will use a publicly available API that requires neither registration nor API key and displays parameters of various cryptocurrencies: https://www.coinlore.com/cryptocurrency-data-api 1
Here is an example of the GET request method I am going to use for illustrative purposes: https://api.coinlore.com/api/ticker/?id=90 2 This request will return the following properties and values:
Now let’s implement this in Valkyrie.
I start with a new level:
Then do a bit of cleanup:
I add a Text entity that I name “Bitcoin display”, where I will display the USD value of a Bitcoin:
Notice that in the Text entity, you have a “text” property which will be used to receive the bitcoin value later on:
I add a DataTable entity that will receive all the data pulled from the API:
Now we have 2 actions to add to the Timeline and we are all set.
First I drag&drop a DataTableReadURL action, which will allow me to call the API, onto the DataTable entity:
I then set the DataTableReadURL properties:
Lastly, I drag&drop the entity EntitySetProperty, which will allow me to change the properties of my Text entity, onto the DataTable entity:
I then set the EntitySetProperty properties:
This is it, I just created an app that will retrieve the USD bitcoin value in real-time from a web API:
Note that it can take a little time before the USD value of the bitcoin is refreshed. These parameters depend on the API provider.
You can do any HTTP GET request which receives a flat JSON object as response.
If you need to process complex APIs (APIs that respond with deep hierarchies or arrays), you will need to create a small proxy server to provide a clean HTTP interface to your Valkyrie application.
Feel free to ask for help in our Discord server if you need help with getting your data in Valkyrie.