Constraining API Call / Fetch to once per day / usage - React Native - react-native

I have searched everywhere and just cannot find an answer for this. What I want to do can be described as follows:
On a user's first time opening the application for a given day, make an API call. Store the API call in local storage, and then for the rest of the day, simply rely on the stored data in local storage (data comes from local storage as opposed to API call now).
However, once that full day passes, a new API call is made the next time the user opens the application and that data is used to update the data in local storage. Rinse and repeat. Is there a way to do this?

You can store the date of when the last API call was made, for example, lastAPIFetchDate, then each time the app opens you compare lastAPIFetchDate with today's date and if the lastAPIFetchDate is before today's date, make the API call, if not, get the data from the storage.

Related

Vue API Best Practice Duplicate Calls (Vuex?)

Within my app there are multiple pages that display a drop down of "clients". The select options are loading via an GET call made in Axios. Every time a page is displayed it makes that get call.
I'm curious if it's better to store those clients in Vuex, and then just load them that way so I don't make a call every time? The only thing I am concerned about is when a new "client" is added the best way to tell the app it needs to make a new get call to update the data in Vuex.
There are many possible solutions to this.
You could use a cache in back-end suchlike Redis, or as you said, cache it in the front-end.
You can abstract this caching with a get function which will check a maximum threshold of cache age.
For example, you can set it to last for 15 minutes. If another request is made before it you could answer with the last obtained data, else it will request the data to the server again.

"Whats new" date restriction on API

I am developing an app with the Active Collab API using the What's New endpoint.
I am retrieving this regularly, so I have the latest information. I was wondering if there was a way to specify the activity by date to get the items since then?
For example, instead of getting 50 records and processing the 50 every time, if I could pass a from parameter (with a timestamp) to only collate activity since that time then that would help with both my processing and the size of the request (and knowing how many things have happened since)
Is this possible?
What's New API end point only has a daily filter:
/whats-new/daily/YYYY-MM-DD
Both global and daily What's new API end-points are paginated, so you can loop through responses by providing (and incrementing) page GET argument:
/whats-new?page=2
until you reach records that are older than the timestamp that you are looking for (or get an empty result). At that point, you just break and you have all the updates that were looking for.

Working with Synology Surveillance Station Web API

If is someone that worked with Synology API documentation is here
I wonder if there is any possibility to get a snapshot picture on a certain timestamp (let's say a snapshot from yesterday). I have all the recordings saved on the server grouped in videos of about ~10 min on a full day.
What I managed to do so far is to get a snapshot of the live screen with this API GET call:
http://34.59.110.237:6001/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=GetSnapshot&version=1&cameraId=3&xtamp=1486308916&preview=true&_sid=$currentsid
This will get me each time I call it a print of the current screen, somehow the xtamp=1486308916 (unix timestam) won't take any consideration. I tryed with (time,timestamp,update_time), no luck, any idea ?
The GetSnapshot method from the API SYNO.SurveillanceStation.Camera ist only for the current view.
I have no idea for your problem, but look at the "List" method from the SYNO.SurveillanceStation.Recording API.

Google Fit API - Real Time Data

I am trying to show in my application the steps that the user walked per day in real time but I am not able to. I tried to get the steps using TYPE_STEP_COUNT_CUMULATIVE but I am able to get all the steps from the day that user started using the application.
When I tried to use other type, for example DELTA, it's not working. Not sure if I am missing something. I am able to get the daily steps from HISTORY API but I cannot use them for real time because UI does not allow to use await().
Any suggestions?
The com.google.step_count.cumulative data type represents step count data as a sum since the start of the count. So this is not the one that you need.
From this documentation, it is stated here that Google Fit also provides simple access to the daily total of a specified data type. Use the [HistoryApi.readDailyTotal()](https://developers.google.com/android/reference/com/google/android/gms/fitness/HistoryApi#readDailyTotal(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.fitness.data.DataType)) method to retrieve the data type that you specify as of midnight of the current day in the device's current timezone. For example, pass in the TYPE_STEP_COUNT_DELTA data type to this method to retrieve the daily total steps. You may pass in an instantaneous data type that has an aggregate daily total.
But, if you want a real time data, you need to use the Sensors API together with the Recording API. Source: Record Fitness Data
For more information, check this related SO question:
Get current day's steps during datapointListener google Fit

QuickBooks API - Retrieve only data that has changed

I am building an app that accesses the QuickBooks API v2.
I am looking for a way to retrieve only data that has changed.
For example, from time to time want to be able to check to see if there have been any changes to the chart of accounts in the QB data. Is there a quick way to do this without parsing a large response body? Maybe something like requesting and comparing just a checksum, and then requesting the whole chart of accounts to compare and update if there is a change? Or even just requesting the changes that occurred after a certain date?
This need is not just limited to the chart of accounts. For example, I may want to update historic transaction data, but only with the changes (e.g., a change to an old transaction), not the entire db which can be quite large.
Answer
In further reading the API docs, I should be able to filter the response using the created_at and updated_at metadata.
The filter is called Change Data Capture (CDC)
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0100_calling_data_services/0015_retrieving_objects
<ItemReceiptQuery xmlns='http://www.intuit.com/sb/cdm/v2'>
<CDCAsOf>2010-12-04T09:30:47.0Z</CDCAsOf>
</ItemReceiptQuery>
thanks
Jarred