Introduction

Xweather Javascript SDK

The Xweather JavaScript SDK is an easy-to-use library that allows developers to quickly integrate weather data and imagery from their Xweather subscription into their web applications. You can perform basic Xweather Weather API and/or Xweather Raster Maps requests, or display a fully-interactive weather map using one of the many third-party mapping libraries currently supported.

Follow our Getting Started guide to quickly add weather data and imagery to your web applications.

Requirements + Compatibility

Basic Request Example

The following is a basic example that demonstrates how easy it is to start using the Xweather JavaScript SDK for requesting Xweather Weather API data and Maps imagery once you're set up:

// load the latest observation for Seattle, WA
aeris.api().endpoint('observations').place('seattle,wa').get().then((result) => {
     const data = result.data.ob;
     document.getElementById('obs').innerHTML = `The current weather is ${data.weatherPrimary.toLowerCase()} and ${data.tempF} degrees.`;
});
 
// load the latest radar image for Seattle, WA at 500x300 pixels
aeris.map().layers('flat,radar,counties,admin').center('seattle,wa').zoom(9).size(500, 300).get().then((result) => {
     // append result image to a DOM target
     document.getElementById('map-target').appendChild(result.image);
     
     // output image valid time to a DOM target
     document.getElementById('map-metadata').innerHTML = `Valid: ${result.metadata.validDate}`;
});

Implementation Methods

The Xweather JavaScript SDK can be implemented either in the browser by loading the compiled library from our CDN, or by installing and importing the SDK as an NPM module and importing it into your NodeJS or JavaScript project. Review the Getting Started guide for more information about each implementation and to set up and start using the SDK.

Features

The Xweather JavaScript SDK offers a rich feature set, from basic data and map imagery requests to fully-functional static and interactive weather maps. The core features of the SDK are outlined below:

Feature
Data RequestsConfigure and request data from the Xweather Weather API. Read more about API data requests via the SDK.
Map Image RequestsConfigure and request map imagery from Xweather Raster Maps. Read more about map requests via the SDK.
Interactive MapA fully-interactive weather map using one of several support third-party mapping libraries, including Leaflet (opens in a new tab), Mapbox (opens in a new tab), OpenLayers (opens in a new tab) and Google Maps (opens in a new tab). Read more about setting up an interactive map with the SDK.
Map ViewA lightweight weather map using static Xweather Raster Maps imagery that supports animating weather data. Read more about setting up a basic map view with the SDK.
LegendsAn easy-to-use view component for fetching and rendering one or more weather layer legends in association with map imagery from Xweather Raster Maps. Read more about using legends within the SDK.