Hello,
I am looking for some pointers to good content on how to consume an API.
I have never consumed data from an API before, but my electricity provider gives electricity consumption in 30 minute intervals, so I want to put a project together to help my learning.
I call the API via Curl at the moment..
api-url.com/consumption/?period_from=2021-09-10T16:00:00Z&period_to=2021-09-10T16:30:00Z"
{
"count":2,
"next":null,
"previous":null,
"results":[
{
"consumption":0.713,
"interval_start":"2021-09-10T17:30:00+01:00",
"interval_end":"2021-09-10T18:00:00+01:00"
},
{
"consumption":0.971,
"interval_start":"2021-09-10T17:00:00+01:00",
"interval_end":"2021-09-10T17:30:00+01:00"
}
]
}
So if I want to store this data in my database what's the best way to do this?
- Create some kind of worker to call the API every 30 minutes?
- How do specify the time range to make sure no 30 minute interval is missed or are duplicated?
- How would you handle downtime on my server? Lets say it was offline for 2 hours? How does it go back and fill in the gaps?
- What about a failure on the api end - I presume you would some how re-queue the job?
If there is a good Laracasts video on this? Happy to watch through.
Thanks