Banging my head against the wall - API+JSON+Extract data!

OK I know this type of thing has been reported before and I had read various threads:

Plus I have read the docs:

But no matter what I have tried I cannot get the JSON data from the Faceplusplus API
See docs here : Face⁺⁺

I have attached some attempts but do understand that these are only some attempts that I have made and tried to avoid troubling you good folks here

.

Please can someone help me getting the data from the faces->attributes->emotion->

Also note that the API is returning the JSON as I send it to a label object as text and the values and JSON format show

Also I have the JSON data in question:

{"request_id":"1732116146,454562ca-7765-4065-bcd4-f1bfe4ae0b53","time_used":1048,"faces":[{"face_token":"758b943627609891d98a15faed651949","face_rectangle":{"top":209,"left":677,"width":216,"height":216},"attributes":{"emotion":{"anger":0.000,"disgust":0.000,"fear":0.000,"happiness":99.998,"neutral":0.001,"sadness":0.000,"surprise":0.000}}}],"image_id":"RhHX0oPMUSnudJhnA2qgaA==","face_num":1}

Please note that I am only looking for the emotion data so in my API request I call return_attributes

Thank you

Tim

Got this sorted with the help of this thread API JSON Tutorial (Video) - #15 by tatiang from @tatiang and used the Best JSON Viewer and JSON Beautifier Online site to determine the location of the values in this JSON.

For me this worked : faces[1].attributes.emotion.anger

Now I have got to figure out how to loop through all the emotions and get their names and values

2 Likes

I am struggling with grabbing the emotion names e.g. happiness anger neutral etc any thoughts would be appreciated

Getting the property names requires using a different method. It’s complicated:

Note that the JSON response variable is actual JSON (text) that I copied from your post after formatting it with the </> toolbar button to remove smart quotes that invalidate the JSON. If you are getting a JSON response from an API server, you would just attach the green response block to the get property of object block in my screenshot.

Sorry, thought I was going to need an extra variable for the emotions list but I didn’t. It’s still in the screenshot. But you could also set that variable to the make text from list block to be able to store the list of emotions.

Thanks @tatiang I will give this a go your other thread/guide was really helpful !

TimCS

1 Like

I got a problem, i am trying to make plinko balls in my app. Kinda like this
https://plinko-web-game.netlify.app/ but less complicated and way more simple. I got my pins but the sprite is a square and acts like one too, is there any way to make it work like a circle? And how do you make the scoring like when the ball goes down into the 0.2x or 2x or 1000x for example?

Please start a new topic or find one related to what you are asking about.