Storing data from expensive API queries

Hi,

I have a notebook where I’m making some calls to a GraphQL API which makes a somewhat expensive calculation server-side. This often causes the notebook to break (and gives a “TypeError: Failed to fetch” error).

Is there any way I could store the data from the query so as not to have to query it again each time a user opens the notebook?

Would appreciate any help!

3 Likes

Hi @lagerros,

Although we don’t (yet) offer a programmatic storage solution — it’s easy to download the contents of a cell, and save it as a “FileAttachment” for the notebook to access in the future.

For example, here’s a cell that makes a fetch against a remote NASA API. I open the cell menu and click “Download JSON”:

Then, in another cell, I upload the JSON as a FileAttachment:

… now I don’t have to hit the remote API any more.

(Demo notebook is here)

1 Like

That’s excellent, works very well. Thanks!

1 Like