Degree Days

Degree Days

Weather Data for Energy Professionals

Weather Underground

Access the Degree API using Ruby

This page has some sample code showing how to use Ruby to specify an XML request, send it to our API servers (past the security system), and get an XML response back.

It's not a full client library (like we have for Java, .NET, and Python), but it should work fine so long as you can specify your request in XML, and write some code to parse the XML response.

See the XML API docs for more information about how to specify the data you want in the XML request. There are lots of options, and the XML included in the Ruby code below is just a very simple example to get an API request working.

Many thanks to Thiago Nuic from Wattics who wrote this Ruby code based on our PHP example, and gave us permission to publish it here.

require 'net/http'
require 'base64'

class DegreeDays
  @@account_key = 'test-test-test'
  @@security_key = 'test-test-test-test-test-test-test-test-test-test-test-test-test'
  @@url = ''

  def self.perform_call
    timestamp =
    random = SecureRandom.uuid

    request_xml = %{
                <DatedDataSpec key="dailyHDDForLast7Days">

    digest ='sha256')
    signature_bytes = OpenSSL::HMAC.digest(digest, @@security_key, request_xml)

    request_parameters = {
      request_encoding: 'base64url',
      signature_method: 'HmacSHA256',
      signature_encoding: 'base64url',
      encoded_request: Base64.urlsafe_encode64(request_xml),
      encoded_signature: Base64.urlsafe_encode64(signature_bytes)

    uri = URI(@@url)
    res = Net::HTTP.post_form(uri, request_parameters)
    return res.body

puts DegreeDays.perform_call

Hopefully the example code above and the XML API docs will be enough to get you going, but please feel free to email us if you'd like more help.

It is also worth reading the higher-level integration guide for tips on the various approaches to integrating with the API. We have helped a lot of businesses integrate their software with our API so we are very familiar with the patterns that work well for common use cases.

Choose your Plan and Sign Up Today!

© 2018 BizEE Software Limited - About | Contact | Web Tool | API | Integration Guide | API FAQ | API Sign-Up