API JSON parsing/format into bubble database

Made a freelancer job description as i really want this to be working :smiley: https://codeless.pro/jobs/help-me-get-unstuck397

So i try to figure out how i can format the data from an API i call.
This is the raw JSON:

{
“response”: {
“game_count”: 142,
“games”: [
{
“appid”: 4000,
“playtime_forever”: 48
},
{
“appid”: 50300,
“playtime_forever”: 0
},
{
“appid”: 55100,
“playtime_forever”: 0
},
{
“appid”: 55110,
“playtime_forever”: 0
},
{
“appid”: 55150,
“playtime_forever”: 132
},
{
“appid”: 654310,
“playtime_forever”: 0
}
]
}
}

All i get is a list of “appid” and a list of “playtime_forever” but the two values, despite being in an array, have no correlation it seems. So i can’t figure out if “appid”: 654310 has “playtime_forever” > 200 for example. I can’t display the “playtime_forever” for any specific “appid” because they are not linked in any way.

Is there any way to have the data above be parsed into the database so i can actually use it?
Some people seems to suggest the use of google sheets or charts but i can only see payed plugin in the store for this. I mean i should not have to use a payed plugin just to properly use the data of APIs -_-

EDIT

the editor is set to public, really any help is appreciated am totally stuck with this database problem

1 Like

It is inexplicable why Bubble does not properly handle arrays and subarrays from the API Connector. I keep trying to explain this, but they seem to not understand… or something.

I need to make a video.

so you saying this is indeed not possible? i can’t parse the json data in a way that i can actually use them?

and yeah, i also can’t call any API arrays, otherwise i would do it directly with the API, because the API let’s me filter the APPIDs

Can you share a screenshot of the API connector where it shows it is parsing the result?

I haven’t tried your example yet, but I’ve seen similar before, it should return a structure with games as a list of objects, that you can do something like:

response’s games :filtered (playtime_forever > 0)

And then get the individual field values

response’s games :filtered 's :first item 's appid

The whole result should be storable in the database if you create a data type’s field of type : (select the API result as a type).

2 Likes


not sure if that is what your requested, i created a own plugin to connect to the API not the connector

am gonna try to figure out what you mean with this :slight_smile:

The whole result should be storable in the database if you create a data type’s field of type : (select the API result as a type).

well i think am done with this bubble stuff
it just doesn’t make any sense to me

like really, it’s easier for me to learn all these coding languages than to figure out what bubble wants from me, disgusting, sry my tone but am really pissed since i worked hours on end on this to fix it and tried so many different approaches.

I even tried the dexi.io app because i have the steamIDs and hours played on our forum saved in our mysql
so i can parse the data from that mysql to get a specific set of appids/games only from this list: http://united4games.com/most_played_steam_games/test.html
but i have the same problem again, i don’t know how to get the data into the bubble database correctly and this is what i could come up with: https://i.imgur.com/WESABv0.png
i just need rows i can work with am going crazy because everything is there but i just can’t figure it out.
So yeah, your help is much appreciated :slight_smile: you give me hope that it’s still possible and that it’s just me being stupid, i really hope i am because then it would be a problem that could be solved after all :slight_smile:

Thanks for the screenshots, very helpful.

Very close there, the error does give a clue … You’ve defined the field as a response game, so it would only accept one item of the response games list.

If instead, in the field definition you tick the “list” checkbox, it will accept the whole list.

You can also send the list to a repeating group, and inside each cell you can reference a game’s appid, playtime_forever, playtime_2weeks.

Edit - a huge drawback of this approach is that the structure is frozen, to accept new fields in the games list objects requires re-initializing the API call, which then gives a new definition which can be saved in the database - I’m unsure if it automatically updates it, hopefully it does.

That’s why I’m a fan of keeping it as a JSON text.

What you’re seeing could be a list of texts displayed with commas, or a text with commas, you might find out more if you try to edit the row and the possible list field.

Not sure what you mean with “That’s why I’m a fan of keeping it as a JSON text.” because basically that’s what am trying, since in JSON they are all in an array, so i thought i could do the same with rows, so one row is one array and is correlated to each other.

i already send the list to a group but that does not let me work with it, it’s just a huge list of all games and playhours that is nice to look at but i can’t filter it properly.

i tried to set it up like you said, hope i did it right but it does not seem to work:
i get this now https://i.imgur.com/aStj9RB.png
when i do this https://i.imgur.com/T4d9is1.png

well i have to get into it again tomorrow with a clean head i guess :smiley:

EDIT!!!

it says am a new user and have no replies left, R.I.P

says must be text, that’s why i used text i think

On the API Connector, if you choose the return type to be “Text” instead of JSON, Bubble doesn’t do the parsing, doesn’t setup those funky list structures, and you get the body as text, with the contents of the text in whatever form was sent.

This is often more useful if you are sending it back to another API, using it in Javascript, etc. The drawback is, Bubble doesn’t have any JSON functions and it makes it harder to search/filter etc. But all this can be done on server or client scripts anyway.

image

That looks empty … maybe its just the data editor being funky? What if you use the list in a Repeating Group?

EDIT - I tried something similar, and get the same weird result too.

am finally back let’s hope i can write longer before the next forum restriction kicks in :smiley:

so yeah, i get an empty list with this Steam API.
I just tried it with the Discord API, same thing: https://i.imgur.com/DLfuTSe.png
when i do this: https://i.imgur.com/7eOEpFX.png

no clue how to fix this but basically that’s all i need, a correct listing of the APIs data so i can use it in bubble.

Please tell me am missing something
shouldn’t is just work, i get no errors, everything seems to work but it will have no data but only commas in the database





well i really don’t understand this, i can’t even get the repeating groups data i already see into the database

it just makes no sense to me, please someone help, there must be anyone that just knows whats going on i mean it can’t be like this now, it seems so strange i can’t believe it :smiley:

Your data is in the database, but the App Data tab doesn’t seem to like showing API data structures. It’d be worth raising a bug for this.

You can verify this by setting a repeating group with data source as a search from the database.

Good you have retrieved from the API successfully!

yeah i can call it in the visual editor in the repeating group

but it will still not display anything in teh preview

it has been now with any API i tried, the steam one and the dexi.io i tried to parse like this and it always only shows commas

Try using the API as a data source for the database, and the RG as a view element for either the database or the API.

On your RG data source you have a search for StreamDatas, but do you want to show a bunch of results, each one containing a list of game data, or the list of game data for a single StreamData?

You might need a nested repeating group … I’m a bit confused about your data structures now, the names seem to alter in every post :slight_smile:

yeah because i try all kinds of things, right now :D:

login with steam on our forum > database mySQL > parsing only the game i need > pulling it into a website > extracting the data from the website with dex.io > accessing the parsed data from dex in bubble via their API > making a webhook on zapier and parsing the data there into rows > adding the rows into a google sheet via zapier: https://docs.google.com/spreadsheets/d/1JHs74jc_i_Q3mqw72Euzw8VAWjQ_2fvFSarPKyez74g/edit?usp=sharing

it’s crazy what i came up with i know, am just testing all kinds of approaches and this one is by far the most outrageous

maybe you can just have a look at the editor lol https://bubble.io/page?name=index&id=discordloginv1steam&tab=tabs-1

edit. and yeah the API i can parse into the sheets and i get a nice list, but i can’t seem to parse this nice list as i see it into the bubble database, that is where i got stuck.
So when i could figure out how to get the data i have in the nice RG into the bubble database as rows, i would not need anything else pretty much to get unstuck here

edit2. not sure if you can see the previews https://discordloginv1steam.bubbleapps.io/version-test?debug_mode=true but when you scroll down the list down below, i just need to get that list into the database, with each cell being a row in the bubble database

Hey @VanV

I created a test page to mess around with … https://discordloginv1steam.bubbleapps.io/version-test/test?debug_mode=true

The button creates a new database row from the API result.
The first RG shows the API result.
The second RG shows each StreamData row.
The second RG shows the last saved API result in the database.

There was a problem with viewing the data, caused by privacy rules :

Screenshots

Originally …

I changed the default so all can view, I don’t know what you want with the custom one so I left it broken …

I hope that gets you over the hurdle and back on the track!

Edit - on your index page, the first RG data source is each StreamData row, which means each cell’s execution result is a list, but you are showing the fields as if it is one item.

It would make more sense to show the execution result list in its own RG, this can be done with selecting a single item of StreamData, or by nesting the RG in a StreamData RG.