Weather API and Geolocation jQM Sample App

Sample apps with backend services.

This example​ uses Weather REST API to show the temperature information based on your location.

Sample app uses and demonstrates:

  • jQuery Mobile.
  • Server Code.
  • Invoking an external REST API.

App (UI)

To get the app UI:

  1. Create a new jQuery Mobile app based on the Blank template.
  2. Inside the App Builder, select CREATE NEW > From plugin. Under Examples select Weather API with Geolocation.
  3. Click the Import selected plugin button.
  4. Select Weather as the starter page and click Apply settings.


To get the app backend:

  1. Go to the Server Code page.
  2. Open the Plugins page.
  3. Import the WeatherUnderground plugin. Open the imported script, it should look like this:
var apiKey = "Quickly check weather conditions for a location.";
var location = request.get("location");
var url = ""+apiKey+"/conditions/q/"+location+".json";

var XHRResponse = XHR2.send("GET", url, {});
Apperyio.response.success(XHRResponse.body, "application/json");
  1. You need to sign up for a Weather Underground Developer account to get an API key. Once you have the API key, set it on line 1 in the script. How to find the API key?
  2. If you would like to test the script before using it in the app open the Script parameters tab. Create a parameter called location and set its value to an airport, for example, ​JFK.
  3. Switch to the Run tab and click the Save and run button.

Connecting the UI and the Backend

The last step is to connect the app with the backend.

  1. In Server Code, open the API information tab.
  2. From Service URL, copy the script ID.
  3. Inside the App Builder, open Services > WeatherAPI_service.
  4. In service URL, replace {servercode} with the ID from step #2 (the curly brackets are not needed).
  5. Now you can test the app by clicking the Test button in the toolbar.