How do I contact a API endpoint every 10 minutes and save the data

More specifically I want to create a node.js app, put it on a server

Call a server (only during the day) to receive JSON data

Parse that data

And save that data everyday

What is the best way to do this ?

There is no best way. You’ve indicated that you want to use node (and frankly, the problem doesn’t change even if you change languages or frameworks).

Have you thought about what things you need to accomplish the task? Can you break down the problem further?

Think of it another way.

How do you call a server, receive the response, parse the response, save the response - once?
How do you repeat that again?
How do you repeat that on a schedule?

Thanks for your response, I didn’t get notified for some reason.

Currently I’m able to call the server and receive the JSON response no problem.

I’m also able to wrap that function inside a setTimeout() function

But it only works “locally”, when I run it manually initially.

I want to automate to process, so there is no need me to run it.

Ultimately my goal is to plot out the weekly rain fall on a graph.

Nothing too extravagant really.

Have you tried setInterval()?

You will need to use a scheduler. You can use crontab on linux to run a script at specific intervals.

Yes I have research that and it’s great, I’m looking for a examples/tutorials of the process being initially automated without me to initially “run”

THANK YOU Randall !!! That’s great can you recommend alternatives to crontab, this is my first leap into schedulers

Also what would be the best way to persist the data ?

I was thinking of saving each response into seperate .json files on a DB

Is this a good idea ?

That would require doing it on your Node server