Switch from Current One Call API 2.5 API to 5 Day / 3 Hour Forecast API#12
Open
SheriffKoder wants to merge 1 commit intomixj93:masterfrom
Open
Switch from Current One Call API 2.5 API to 5 Day / 3 Hour Forecast API#12SheriffKoder wants to merge 1 commit intomixj93:masterfrom
SheriffKoder wants to merge 1 commit intomixj93:masterfrom
Conversation
….5 API seems to not be working and ignore macOS metadata files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR migrates the weather widget from using the One Call API 2.5 API to the 5 Day / 3 Hour Forecast API (which uses the same API key from openweathermap and is available for FREE also). The widget derives current weather, hourly forecasts, and daily forecasts from a single forecast API endpoint.
Why
The One Call API 2.5 API is possibly not available and causing an error to users.
The 5 Day / 3 Hour Forecast API is available on the FREE tier uses a single request and fixes the issue of no data available from the One Call API 2.5 API:
How
API Endpoint Change: Updated the API path from
/data/2.5/onecallto/data/2.5/forecastto use the forecast endpoint.Data Transformation: Added a
transformForecastData()function that:aggregateToDaily()helper functionDaily Forecast Aggregation: Implemented
aggregateToDaily()function that:Backward Compatibility: The transformation layer ensures the widget's existing UI components continue to work without modification, as the transformed data structure matches the expected format.
Error Handling: Enhanced error handling to validate the API response structure and provide meaningful error messages if the forecast data is missing or malformed.
Error message that is now fixed: