Aeris API
The Aeris API is one of the most complete and advanced weather APIs available and quickly gives you access to many different types of weather information. Not only is Aeris weather content easy and flexible to use, but our set of mobile and web toolkits integrate with our core API to provide you with everything you need to get weather integrated into any web or mobile application.
Getting Started
- Sign up for an Aeris API subscription service.
- Log in to your account to register your application for an API access key. Each application requires its own unique access key.
- Familiarize yourself with the variety of features available.
- Review our mobile and web weather toolkits to speed up your weather content development.
- Find the endpoints and actions that provide you with the data you need in order to work with the API directly.
Requesting Data
Once you’ve signed up for the Aeris Weather API and have an active client id and secret for your application, you’re ready to start creating some requests. The following are some very basic code samples for various programming languages to help you get started with the API. Also, watch for our Aeris Web toolkit for PHP to be released in 2013 to help plug weather into your custom applications using our API with even more ease. The Javascript SDK was released in 2012.
PHP
<?php
// fetch Aeris API output as a string and decode into an object
$response = file_get_contents("http://api.aerisapi.com/observations/seattle,wa?client_id=CLIENT_ID&client_secret=CLIENT_SECRET");
$json = json_decode($response);
if ($json->success == true) {
// create reference to our returned observation object
$ob = $json->response->ob;
echo sprintf("The current weather in Seattle is %s with a temperature of %d.", strtolower($ob->weather), $ob->tempF);
}
else {
echo sprintf("An error occurred: %s", $json->error->description);
}
?>
Javascript (with jQuery)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$.ajax({
url: "http://api.aerisapi.com/observations/seattle,wa?client_id=CLIENT_ID&client_secret=CLIENT_SECRET",
dataType: "jsonp",
success: function(json) {
if (json.success == true) {
var ob = json.response.ob;
$('#js').html('The current weather in Seattle is ' + ob.weather.toLowerCase() + ' with a temperature of ' + ob.tempF + '°');
}
else {
alert('An error occurred: ' + json.error.description);
}
}
});
});
</script>
<div id="js"></div>
Ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'json'
url = 'http://api.aerisapi.com/observations/seattle,wa?client_id=CLIENT_ID&client_secret=CLIENT_SECRET'
buffer = open(url, "UserAgent" => "Ruby-Wget").read
#convert JSON data into a hash
response = JSON.parse(buffer)
ob = response['response']['ob']
print "The current weather in Seattle is " + ob['weather'].downcase + ' with a temperature of ' + ob['tempF'].to_s() + "\n"
Python
import urllib2
import json
request = urllib2.urlopen('http://api.aerisapi.com/observations/seattle,wa?client_id=CLIENT_ID&client_secret=CLIENT_SECRET')
response = request.read()
json = json.loads(response)
if json['success']:
ob = json['response']['ob']
print "The current weather in Seattle is %s with a temperature of %d" % (ob['weather'].lower(), ob['tempF'])
else:
print "An error occurred: %s" % (json['error']['description'])
request.close()