coinbase pro api - historic prices - invalid interval - coinbase-api

I am trying to make an API call to retrieve historic BTC-USD prices with the coinbase pro API.
I am defining the specified parameters available:
start(Start time in ISO 8601), end(End time in ISO 8601) and granularity(Desired timeslice in seconds).
I get however the message: "Invalid interval" for the below request:
https://api.pro.coinbase.com/products/BTC-USD/candles?start=2016-01-30T19:06:05+00:00&end=2016-02-06T19:06:05+00:00&granularity=86400
The dates are in ISO 8601 and I can not figure out why coinbase would not accept this interval.
Does anybody know why this is not accepted as a valid interval?
Thanks

Thank you JJJ for the link.
I forgot to url encode the dates for the REST Api request.
Encoded, this works now:
https://api.pro.coinbase.com/products/BTC-USD/candles?start=2016-01-30T19%3A06%3A05%2B00%3A00&end=2016-02-06T19%3A06%3A05%2B00%3A00&granularity=86400

Related

Cannot retrieve correct historic rates using Coinbase Pro API

I'm trying to retrieve historical data for coinbase products. According to their documentation, it should be sufficient to perform a request like this one:
curl "https://api.pro.coinbase.com/products/BCH-EUR/candles?granularity=60&start=2018-10-05T14:00:00.000z&stop=2018-10-05T14:10:00.000z"
I've set following parameters:
granularity to 60 (seconds)
start to 2018-10-05T14:00:00.000z (iso 8601)
end to 2018-10-05T14:10:00.000z (iso 8601)
I'm asking data for 10 minutes, with a granularity of 60 seconds, so I was expecting ten candles data.
Instead I obtain a set of 300 candles, that's the maximum, and the timestamps are also wrong. For example the first value is:
[
[
1624119060,
484.31,
484.31,
484.31,
484.31,
0.11766122
],
...
]
The timestamp is the first value, and according to an epoch converter, it's equal to Saturday, 19 June 2021 16:11:00, that's the day in which I performed the request, not the timestamp that I was expenting for that candle data according to start date that I've set.
I don't know what I'm doing wrong. What should I do in order to retrieve data correctly?
It should be end, not stop. You quote the doc correctly, but the param itself is incorrect. Already voted to close this one as typo-based. :)
What's funny about their API is that if one of the params is omitted, another is just ignored. That's why you end up having incorrect timestamps in your response.

Is it possible to get the price of bitcoin in USD from the coinbase API for a specific time in the past?

GET https://api.coinbase.com/v2/prices/:currency_pair/spot
This price seems to be the current price
This question already has answers. Copy and pasted from here: Coinbase API v2 Getting Historic Price for Multiple Days
Any reason you aren't using coinbase pro?
The new api is very easy to use. Simply add the get command you want followed by the parameters separated with a question mark. Here is the new historic rates api documentation: https://docs.pro.coinbase.com/#get-historic-rates
The get command with the new api most similar to prices is "candles". It requires three parameters to be identified, start and stop time in iso format and granularity which is in seconds. Here is an example:
https://api.pro.coinbase.com/products/BTC-USD/candles?start=2018-07-10T12:00:00&stop=2018-07-15T12:00:00&granularity=900
EDIT: also, note the time zone is not for your time zone, I believe its GMT.

How to specify time in Azure AD Sign In REST API request

I need to retrieve the data after a specific period of time in order to avoid duplication. I can filter out based on the date. On filtering based on today's date, there is repetition in signIn data for the date for consequent requests
I have tried the filtering criteria for the following API
Ref link: https://learn.microsoft.com/en-us/graph/api/signin-list?view=graph-rest-1.0&tabs=http
Sample Request I have tried : https://graph.microsoft.com/beta/auditLogs/signIns?&$filter=createdDateTime gt 2020-09-29
I need to specify the time in this request...Any ideas ..?
Thanks in Advance
You're on the right track! The filter you're using also accepts a time.
If you check the List sign-in response you'll see the format Microsoft uses to specify the date and the time in out field.
Try this URI (for all items after 2020-09-29 19:00:00 (UTC as noted by the z at the end)):
https://graph.microsoft.com/beta/auditLogs/signIns?&$filter=createdDateTime gt 2020-09-29T19:00:00z

Moment.js Date Returning Invalid

I have a React app that is parsing some dates using Moment.js/Timezones. I'm getting data from an API, and many dates return correct and are parsed but a few aren't. For example, this date: 2018-04-03T02:10:00Z parses correctly where as this one does not: 2018-04-03T01:40:00Z. I don't see any reason why this should be the case.
I am using moment.timezone to guess the users timezone:
this.state = {
userZone: moment.tz.guess()
}
and then mapping through my API response and outputting the date (or state of the game if in progress).
{this.props.status === 'Scheduled' ? moment(this.props.gameDate, 'YYYY-MM-DDTHH:MM00Z').tz(this.state.userZone).format('h:MM A z') : this.props.status}
I'm pretty stumped as to why this is happening to only a few dates and have actually been spinning my wheels on this off and on for 4 months... Any thoughts? Thanks!
You have some issue in the way you are parsing your input. Since it is in ISO 8601 compliant format you can use moment(String) instead of moment(String, String).
You code could be like the following:
{this.props.status === 'Scheduled' ? moment(this.props.gameDate).tz(this.state.userZone).format('h:mm A z') : this.props.status}
In your question you are using 'YYYY-MM-DDTHH:MM00Z' as format parameter of moment(String, String), the problem is that format tokens are case sensitive: uppercase MM stands for month's number while lovercase mm stands for minutes. 2018-04-03T01:40:00Z gives invalid date because with your code you are tring to parse 40 as month number.
See here an example on how to use moment(String, String) to parse ISO 8601 compliant inputs and take a look at moment.utc if you want to explicitly parse you UTC input in UTC mode.

Correct Way to Pass Dates from Angular to Web API 2

I have an Angular application that takes dates (date only not time) and posts them to a Web API 2 REST service. We are running into an issue when someone from India uses the application due to timezone issues.
Currently the Angular app is converting the date into ISO8601 format in UTC timezone and sending them to Web API. When the data is received on the Web API side, the date ends up being incorrect. If 6/21/2016 was put into the form, the date ends up coming over as 6/20/2016. The desired solution is to have the actual date value entered in the form be the date value received by the API.
One proposed solution is to treat the dates as strings instead of Dates and then just pass the date portion. This just seems like a hack to me and doesn't seem like the "correct" way of doing it.
What is the correct way of handling this situation?
Given the fact that the application has a lot of date field inputs is there an easy way to implement the solution across all Date input values?
The date format yyyy-MM-dd will be accepted in US / India so you can pass it so to your WebAPI. In JavaScript before posting you can alter the date like this.
$scope.MyDate = $filter('date')($scope.MyDate, 'yyyy-MM-dd', timezone);
If you want time too, the format will be yyyy-MM-ddTHH:mmZ

Resources