Different methods for working with forecasts that are currently populating the API.
Spire Weather prioritizes the quickest possible delivery of the latest global forecast data. As a result, forecasts with the most recent issuance time in the API can be incomplete while remaining lead times are still being populated.
For an overview of Spire’s forecast refresh rates and the difference between issuance times and lead times, see Forecast Resolution, Range, and Refresh Rate.
When Complete Forecasts Matter¶
Some use cases require always having the most recent forecast data, which is why Spire issues forecasts while they are processing rather than waiting for them to complete. Other use cases require always having a complete forecast issuance.
In those situations, use one of these approaches:
Option 1: Specify the Previous Issuance Time¶
Explicitly request the previous issuance time through the API. Both the Point API and File API support an issuance (or issuance_time) parameter.
Example — Point API:
https://api.wx.spire.com/forecast/point?lat=42.32717&lon=-91.62078&issuance=2020-04-28T00:00:00+00:00Update the issuance time to a recent value that is available in the API at the time of your request.
Option 2: Wait for the Latest Forecast to Finish¶
Check the size of the returned data array against the expected size for your time bundle. Only treat the forecast as complete when the count matches.
Expected forecast sizes by time bundle:
| Time Bundle | Lead Times | Description |
|---|---|---|
short_range_high_freq | 25 | 1-hour intervals from 0 to 24 hours |
medium_range_std_freq | 29 | 6-hour intervals from 0 to 168 hours |
medium_range_high_freq | 49 | 1-hour intervals 0–24h, 6-hour intervals to 168h |
Example — Python:
def get_expected_forecast_size(time_bundle):
if time_bundle == 'short_range_high_freq':
return 25
elif time_bundle == 'medium_range_std_freq':
return 29
elif time_bundle == 'medium_range_high_freq':
return 49
return NoneA code sample using the File API with medium_range_std_freq demonstrates downloading forecast files only once the full forecast has finished populating.