Amazon Product Advertising API, timestamp issue - api

Integrated Amazon Product Advisement API with my own application, It's working fine but the problem is:
To access the API we need time stamp, when I put the code on the server ( which is in other country), and used the server time stamp, then API gave the following error in the XML: "Request has expired. Timestamp date is XXXX-XX-XXTXX:XX:XXZ",
but when I enter my own time zone where currently I am, then its start working fine. Why API is working fine with client side timestamp, on the other hand all calculation related to API are happening on the server side.
I consult the following Developer document of Amazon API, but no avial.
Product Advertising API Developer GuideAPI Version 2011-08-01

var currentdate = new Date();
currentdate.toISOString();
This is how I got the time stamp for Product Advertising Api.

I consult the following Developer document of Amazon API, but no avial. Product Advertising API Developer GuideAPI Version 2011-08-01
Hum, this document clearly state the Timestamp parameter MUST be represented in Universal Time (UTC); You cannot send a local time, unless, by chance (which might be the case for your personal location) you happen to be on the same time as UTC:
"• Timestamp—Required. There is no default value. The time stamp you use in the request must be a
dateTime object, with the complete date plus hours, minutes, and seconds (for more information, go
to http://www.w3.org/TR/NOTE-datetime).This is a fixed -length subset of the format defined by ISO
8601, represented in Universal Time (GMT): YYYY-MM-DDThh:mm:ssZ (where T and Z are literals).
Important
If you are using .NET you must not send overly specific time stamps, due to different
interpretations of how extra time precision should be dropped. To avoid overly specific time
stamps, manually construct dateTime objects with no more than millisecond precision."

Related

Constraining API Call / Fetch to once per day / usage - 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.

"No 'Access-Control-Allow-Origin' header" error when making a request to a public API

This is the documentation of the API I'm trying to make a request to.
Relevant section:
Public Data Functions
Ticker
GET https://kiwi-coin.com/api/ticker/
Returns JSON object:
last - last BTC price
date - price date
high - last 24 hours till date price high
low - last 24 hours till date price low
vwap - last 24 hours till date volume weighted average price: vwap
volume - last 24 hours till date volume
bid - highest buy order
ask - lowest sell order
Here's my code:
$.ajax({
type: "GET",
url: "https://kiwi-coin.com/api/ticker/",
});
Yep, there's no way of handling the response. Ignore this for now,
I'm just focusing on getting the request to work.
Here's the error I get in the console:
Failed to load https://kiwi-coin.com/api/ticker/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://cloud-rooster.glitch.me' is therefore not allowed access.
What am I doing wrong? This API works for other users (e.g. bots).
I checked out the other questions with a similar title, but from what I could make out the answers all involved making changes to the server, which isn't an option in this case.
If the API server doesn't support CORS, there are two options:
JSONP. Though you can't make cross-origin XHRs without adequate permission, you CAN include a JavaScript file from anywhere. If the API server returns something like callback({ json data ...}), then you can use the data without having to jump through hoops. However, it doesn't seem like KiwiCoin supports that.
Run your own server from the same origin as your client application (probably the same server that hosts your HTML/JS files), and have endpoints on your server that forward to the API server. This is foolproof.
One thing I noticed from looking at your code is that you have calls to process.env, which doesn't exist in the browser. That might be the sign you need to try option #2!
It turns out I was running the function from the client-side (in the browser), rather than server-side (in a Node.js environment).
Duh!
Problem solved.

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

Jawbone API integration with our health wealness app not returns data

We have integrated Jawbone web API with our health tracker app.
We are using the device, Jawbone UP 24 for our testing.
The Connect part has been working well from our App. But the syncing always return empty response as below.
data response {"meta":{"user_xid":"RCLWx75WGKTdnY0L4UyFZg","message":"OK","code":200,"time":1464848584},"data":{"items":[],"size":0}}
Jawbone User Access token sent in header :
Je5CDuGC9OSc-05UAifnK9kVk6thTRHewCwuwXuPuTo7mW7qLWnnd2I4ljqtCw-RlXB3v78Ji6VXW2MSxp0B_VECdgRlo_GULMgGZS0EumxrKbZFiOmnmAPChBPDZ5JP
StepRequest URL:
https://jawbone.com/nudge/api/v.1.1/users/#me/moves?start_time=1464796800000&end_time=1464848584617
We follow the steps as per the document in this link - https://jawbone.com/up/developer/.
We are worried that it's not working because the API supports only the new devices (Jawbone UP 2, 3 and 4) not for the Jawbone UP 24.
The issue is that your start_time and end_time are in milliseconds whereas they should be seconds.
This request should get the step data you're looking for:
https://jawbone.com/nudge/api/v.1.1/users/#me/moves?start_time=1464796800.000&end_time=1464848584.617
Here's the definition of start_time and end_time from the documentation for the moves endpoint:
And the Wikipedia page for Unix Time defines Epoch time as:
Unix time (also known as POSIX time or Epoch time) is a system for
describing instants in time, defined as the number of seconds that
have elapsed since. . .

Xcode 6: parse online calendar

I am currently creating an app, in which the user is able to book devices (which are provided by a json file) for a certain time period (start date - end date). I was planning to use a online calendar, such as http://30boxes.com/welcome.php to check if the requested device is currently in use by another user at this period of time.
What might be the best strategy to parse that online calendar?
just noticed this website has an API, which makes it super-easy to set and get the calendar data. I feel stupid right now: http://30boxes.com/api/