Fetch Column

Glide Fetch Column

column.sh/fetch is an experimental code column that fetches JSON data from a public API and transforms it with an optional jq query.

Example: Fetch a Cat Fact

  1. Add column at https://column.sh/fetch
  2. Set URL to https://cat-fact.herokuapp.com/facts to fetch cat facts.
  3. Set query to .[0].text to get the text of the first fact.

Development

16 Likes

For those testing this on a new app and a new Glide Table. When I followed David’s instructions no data was fetched at first. Once I added some text in the first row of the table (in another column), then only was the data fetched.

A table with no rows has no rows, and therefore no cells, and nothing to display ;D

(I also got confused by this!)

1 Like

Can this XC column be modified so that it accepts an API key for not-so-public APIs? I imagine that the code would need to accept a header parameter? JS and JQuery are beyond my expertise so forgive my naiveness.

1 Like

You can sometimes put the key in the URL like URL?key=...

Managed to do this in about 15 minutes…scan a food packaging barcode…get some data.

5 Likes

Geocoding!

7 Likes

Great Job! Would be great if you did a tutorial on how you did this.

1 Like

Sure thing. I’ll make one tonight.

1 Like

Thanks @david

Now, I can give a second try to that weather app that I started a long time ago.

5 Likes

Haha that was a long time ago my friend.

@ThinhDinh

You were the one behind the scripts. Without you, I don’t think I’d have started that app at all.

Thanks man!!

2 Likes

As promised:

9 Likes

@Robert_Petitto I really need to find some time to sit down and play with all of this, but it looks like jq query may be able to pull back multiple values at once. From what I see with your setup, you are making three separate api calls, which works, but could be better if it was a single call. I wonder if you can specify all values and have them returned in a delimited list, which could be split into an array and separated out with single value columns. That’s the hard way…on the other hand, you could retrieve the entire json object and use David’s json transformation column (Jq (JSON transformation) Column) to get the values you need. Either way, it would reduce three api calls down to one…especially if there are limits on how many calls you can make within a given time period.

4 Likes

@Jeff_Hager

This is what I did yesterday.

I use David’s column to retrieve the Json then use Single Values and Split columns to get the info I needed.

5 Likes

The only thing with splitting it that way is that JSON doesn’t necessarily need to be structured with everything in a certain order. I mean, the hierarchy matters, but the order of items within a node could be in any order because each piece of data is qualified by name. If the json layout is stable, then you are pretty safe assuming the positions of each piece of data, but I wouldn’t assume that, as a json object could be updated in the future to include or exclude data. The only difference to what I was pointing out to Robert, is that jq query lets you specify which one (or possibly more) parts of the object you need. David’s other JSON Transformation column also lets you specify which parts you need, so you don’t have to rely on the structure of the JSON object always being the same. You just directly specify what you need out of that object and it will be returned, without relying on positions of everything in the json string.

6 Likes

Thanks for pointing that out. :exploding_head:

I will check out the other column and work on a better solution!!!

1 Like

Like this? So, theoretically, this will result in a snappier app?

4 Likes

Look at me learning stuff! @Jeff_Hager @david

5 Likes

image

Awesome! Even better that you can join multiple together! Probably a negligible speed improvement unless the api takes a long time to run on the remote server, but definitely reduces the load of having to run it multiple times.