How to obtain the timestamp of the current time range in the dashboard in Grafana, which can be the start time and end time?

Is there an API that can be directly obtained

No, there is no API. But there are variables for that: