Script Usage

If you are developing a web application or just need to use data from your Aeris subscription on a web page, then the browser-based method of using our JavaScript SDK is recommended.

Once you have an active Aeris API account and access keys for your application, follow these steps to get started using the JavaScript method:

Step 1: Include the library’s script file from our CDN:

Step 2: Set your account access keys when the page and scripts have loaded:

Step 3: Start using the library by accessing the available convenience methods on your AerisWeather instance:

<!-- 
STEP 1: 
Include the library's script file from our CDN.
-->
<script src="https://cdn.aerisapi.com/sdk/js/aerisweather.min.js"></script>

<div id="obs"></div>

<script>

    window.onload = function() {

        /**
         * STEP 2
         * Set your account access keys when the page and scripts have loaded.
         */
        var aeris = new AerisWeather('CLIENT_KEY', 'CLIENT_SECRET');
    
        /**
         * STEP 3
         * Start using the library by accessing the available convenience methods on your `AerisWeather` instance.
         */
        aeris.api().endpoint('observations').place('seattle,wa').get().then((result) => {
             var data = result.data.ob;
             document.getElementById('obs').innerHTML = `The current weather is ${data.weatherPrimary.toLowerCase()} and ${data.tempF} degrees.`;
        });

    };
</script>

Review the Loading Data guide for information on getting data into your application now that you have everything set up.