fahdshaykh's avatar

Binance API how to get price ticker with specific date time.

how to fetch with specific date or date time i have searched with api.binance.com/api/v3/ticker/24hr?symbol=BTCUSDT but i want to fetch with etc. api.binance.com/api/v3/ticker/1274123617?symbol=BTCUSDT in this url after ticker the number is unix date time (2022-05-17 19:13:37). but unfortunately i can't get response.

0 likes
1 reply
tisuchi's avatar

@fahdshaykh Can you try converting unix timestamps in milliseconds?

For example:

$startTimestamp = strtotime('2022-05-17 19:00:00') * 1000;  // multiply by 1000 to convert to milliseconds
$endTimestamp = strtotime('2022-05-17 20:00:00') * 1000;  // multiply by 1000 to convert to milliseconds

$url = "https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1h&startTime={$startTimestamp}&endTime={$endTimestamp}";

Please or to participate in this conversation.