Calculate date range for number of bars back

Using the Alpaca Data API v2, I would like to get the most recent “n” bars ending at date “x”. However that API requires a “start date” value. Is there a way to skip the start date and just use end date and limit? Or can I calculate what the start date needs to be based on the timeframe and bar count?

Any help would be greatly appreciated!