GET request and JSON to Table or Excel

Hi there,

Even though I followed multiple forum threads on this topic, I am still not able to make this work with my API connection. In the attached workflow, I have given the API URL which should filter to either only 1 row of data or 7 rows of data but somehow the output contains huge number of rows (many of them look like metadata and not required).

Can someone please help in setting this correctly so that finally I can either have the JSON to Table or JSON to Excel file?

I am not aware of the complexities of API and responses and hence it’s more troubling to me.

Thank you!

JSON data extraction.knwf (36.4 KB)

Hi @ashu_eureka

Welcome to the KNIME Community!

Can you please clarify what your desired output is? I see a lot of animal related attributes in the JSON so I assume that is what you want to extract and have in a table?

Hi @ArjenEX - Thank you for your reply!

I went through your earlier replies in some other forums posts as well. They were pretty detailed.

In this one, yes I need all the available attributes in a table. This is how it looks in table. I can download the CSV from there but I need the data through API.

Thank you!

Here the same flow with corrections, BUT CSV file is better to work with data and file size.

JSON data extraction-denis.knwf (494.3 KB)

Try to keep the same question on the first topic, it economize time and answers from the partners for the same problem.

BR, Denis

1 Like

Thank you @denisfi!

I can see how you have configured the two JSON Path nodes to get the relevant information and then used the Ungroup and JSON to Table nodes to get the final data. I would have never got around that in such a short time.

I had already connected to CSV and got the data but the problem was to get it through API and hence this hassle as I have very basics understanding of APIs which is not sufficient here.

Sorry, I did not get what you meant by

Did I miss anything? Please suggest so that I am aware for the next time.

Thank you so much again!

Hi @ashu_eureka ,

As @ArjenEX suggest, I’ve posted before about the same topic that could be continued with new replies for it. BUT, as a new approach here with json, you can work with the same source with 2 kinds of branch: CSV or JSON.

API can give you more details and ways to create great workflows and automate it.

SO, keep going and if you need anything else, just call us, ok?

BR, Denis

Hi @ashu_eureka

The double JSON Path is not required. If you create a collection list based on $['features'][*]['attributes'] ,ungroup it and then JSON to Table like you already have then you also get the desired output.

Make sure the List checkbox is set.

Small trick in case you are not aware: you can make your life easy by using the JSON cell preview in the lower section of the config window. If you click on the opening bracket of “attributes”, you’ll see that the entire content of that element will light up in gray. This means that if you query “attributes”, all highlighted information will be included.

image

If you click Add single query, it will extract that individual group. If you click Add collection query, it will extract all groups of “attributes”. Once you have added the JSONPath, all information that will be extracted turns blue. This way you can verify if your path works as desired. In this case, you’ll see that it extracts all groups of attributes accordingly.

3 Likes

This is great explanation as usual! Thank you so much for teaching me how this node works with tricks/tips.

Best Regards!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.