A condition that impacts people no matter where they live is weather. For some applications, it is important to capture current weather or the forecast to provide the best user experience. Because weather conditions happen at locations, HERE offers a Weather API to make sure developers can obtain what they need for their solutions. In addition to being offered as a RESTful API, AWS developers can include the weather feature quickly within their own development environment using the AWS Serverless Application Repository.
This post will show how you can deploy HERE Weather Serverless Application for use in your development projects. This will allow you to query location data from HERE via your own custom API! To accomplish this, you will need credentials at the following:
Deploying the HERE Weather Serverless App
After account credentials are confirmed, to find any serverless application, browse to the AWS Serverless Application Repository.
After clicking the "Browse all applications" button, you will be prompted to do your search. Type "HERE Weather", then select the Places result as shown below.
You will be redirected to the landing page for the Weather application. Under "Application settings" enter your HERE REST API Key (obtained from your developer profile) in the highlighted field "HereApiKey"as shown below, then deploy.
Also note the highlighted link above to the technical documentation for instructions on how to implement. After selecting deploy, it will take a little time for the process to complete. You are prepared for the next step once you see the "Your application has been deployed" message shown.
Accessing Your Weather Application
Part of the newly created Weather application is the API endpoint to execute it. The following screen capture shows how to execute a simple test via the AWS API Gateway:
Accessing from HTML Client
For testing from HTML client, you may need to go into the source code of the lambda function and uncomment the headers as shown below:
The above script calls a constructed URL from all the consts declared which points to the new weather application via Amazon API Gateway. You must replace the value of
YOUR-API-GATEWAY-ID with the value generated from your API Gateway when the weather app was deployed. Running the script in the browser shows a weather info alert when the map is clicked on as seen below.
For more information, please enjoy our recorded session on this topic: