I just created a list auto bubble and would like to find out how I can change the content of an automated list.
Here is an example of what you can do with the “View more” button when you create a “List auto” bubble thanks to an API.
In this thread, we are using the Asteroids - NeoWs API from NASA, which is available here.
The aim of this topic is to show you how you can change the content from an automated list when you click on a button. More specifically, we’ll show you how you can go back in time in the NASA API so that we can display data from previous days.
We chose to show how to create a “List auto” bubble with today’s IDs and names of near earth asteroids. Here is what it looks like in the aforementioned API:
First of all, you need to get access to today’s date and reformat it to use it after in your API call.
In order to do this, you’ll have to create an operation bubble and then add the following modifications:
- Click on “+Add” and select “Get current date” in the drop down menu:
Then create a data key called “date”, which must be a “Number”:
Here is what your first operation should look like. It allows you to get Unix time:
- Now you’ve got the the Unix time, you’ll have to convert it into the international ISO 8601 standard by doing the following:
- Then you need to split the date (which is currently stored in “date_string”), because at this point it looks like this: “2022-03-22T14:24:42.000Z” and you only want the beginning (“2022-03-22”) that you are going to use in the API call afterwards. To split the date you need to create a new data key called for example “date_split”:
And then use it to store the list you are going to create by splitting the date into two different parts:
5. Then you need to store the first part of the date into a new data key that you can call “date_day”:
“Date_split” can be found here (it’s item 0 on the list you’ve just created):
At this point, this is what you should see in the data manager if you click on this very operation bubble in the “tests” section:
Now that you have today’s date in the right format stored in a data key (“date_day”), you are going to be able to use it in an API bubble (don’t forget to link your operation bubble to your API bubble by the way), as a “start_date” but also as the “end_date”:
Then you need to retrieve and store the information you are going to use in the “List auto” bubble. In this API (as shown beforehand), the path to get those data is “near_earth_objects” and then the date, meaning you also need to use the newly created “date_day” here:
Then, you can link this API bubble to a brand new “List auto” bubble where you can use the information from the API call to display a list of today’s IDs and names:
If you want to have access to yesterday’s IDs and names, you need to scroll down to find the “View more” button (you can rename it if you want) that you are going to link to a new operation bubble (you can call it “operation 2” for example):
This operation bubble is here to remove a day from today’s date:
- First you need to subtract a day from “date_day” and store this new data inside a data key you can call “date_day_before”:
Then like before you are going to get something like this : “2022-03-21T00:00:00.000Z”, meaning you need to do the same thing as above:
Once you’ve done all that you just need to link your operation bubble to your API bubble:
Here what you should get the first time the “List auto” bubble comes up:
And here is what you get if you click on “View more”: