API request blocks

I am having a heck of a time trying to access API data.
I am building a simple app to get Stock Info. From Alpha Advantage.
When I pull the URL directly and put it in a browser it works.
But I have tried a million ways to get it to work using the Set blocks and get null.
My goal was to have user defined parameter (stock ticker) and hard code the apikey etc.

You’ll need to post the full JSON response you’re getting from the API as text and use the </> button in the toolbar to format it (which removes smart quotes). It’s easiest to set a text input’s text to the green Response block so that you can select the text and copy it.

Without seeing the JSON, it’s almost impossible to answer your question about how to parse it.

I do have a tutorial that may be of help: API JSON Tutorial (Video)

Thanks!
I have actually watched your video. It was a little more complicated than what I was trying to do.
I will try to post the code and the response. Appreciate your response!!

André

1 Like

CALL WebAPIStocks GET
then do IF Error
DO Set LabelDescription Text to Error
ELSE Set LabelDescription Text GET PROPERTY “OVERVIEW”
OF OBJECT - GET OBJECT FROM JSON - RESPONSE

Hope this makes sense. would be easier if I could just share Block image

Is there a reason you can’t post a screenshot? You can copy and paste images into forum posts or use the Upload button in the editing toolbar above each post. Or you can post a link to your project.

You haven’t provided the JSON response so there’s no way I can answer your question. Can you do that or at least provide the API url you’re using to get that response? The best way to copy the JSON response is to set a text input’s text to the green JSON response block and then copy and paste the result into a forum post (be sure to format it using the </> in the editing toolbar to remove smart quotes).


If I put the whole string into the URL and test it like you suggested, I get a good response. If I plug parameters into the blocks, I get Null.

My goal is to be able to enter the Stock ticker and get the company info. But I wanted to at least start by retrieving the data with the ticker hard coded.

The first step when troubleshooting an API call is to make sure you can get a response. So I would set a text input’s text (or a label’s text) to the green response block. After that, when getting a specific property, make sure that property exists in the JSON response. If you paste the JSON response from a browser or from a text input into Best JSON Viewer and JSON Beautifier Online, you can see that there is no property called “OVERVIEW”.

Which value are you trying to get from the JSON? For example, if you wanted “IBM”, you would get the property “Symbol” of the object.

1 Like

That worked! I wanted to pull description.
THANK YOU!!!

1 Like