When all the input information you have is the amount of time your device needs to be consuming or exporting energy, call the time-slots API endpoint.

FlatPeak will use the Location tariff and, if present, data on local generation to find the lowest (or highest) cost time slots within the specified time period. For example, you can find the lowest-priced 2 hours within a given time period.

Example Request
curl --request GET \
  --url 'https://api.flatpeak.com/slots/time/loc_641b90b758fb8e6293716e40
  ?start_time=2023-06-15T09:00:00Z
  &end_time=2023-06-15T13:00:00Z
  &segment=LOW
  &duration=120' \
  --header 'Authorization: Bearer <token>'