Project

eia_fuel

0.0
Low commit activity in last 3 years
No release in over a year
API interface for fetching data published by the US EIA.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 0.11
~> 10.0
~> 3.0

Runtime

>= 1.0
 Project Readme

EIA Fuel

Use this gem to fetch data published by US Energy Information Administration (eia.gov) and delivered via their public API.

You will need to register for your own API key on their website in order to use the gem.

View all the API endpoints at the EIA API query browser.

Installation

Add this line to your application's Gemfile:

gem 'eia_fuel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install eia_fuel

Usage

Require the gem

require 'eia_fuel'
# Instantiate and use client instance
client = EiaFuel::Client.new(your_api_key)

# Use the client to fetch a series
series = client.get('PET.EMD_EPD2D_PTE_NUS_DPG.W')
#=> #<EiaFuel::Series:0x00007f7f4e10b380 ... >

# the series contains the information you want
series.name
#=> "U.S. No 2 Diesel Retail Prices, Weekly"
series.data
#=> [#<struct EiaFuel::Tuple date=#<Date: 2018-07-02 ((2458302j,0s,0n),+0s,2299161j)>, price=3.236>,
 #<struct EiaFuel::Tuple date=#<Date: 2018-06-25 ((2458295j,0s,0n),+0s,2299161j)>, price=3.216>,
 #<struct EiaFuel::Tuple date=#<Date: 2018-06-18 ((2458288j,0s,0n),+0s,2299161j)>, price=3.244>,
 #<struct EiaFuel::Tuple date=#<Date: 2018-06-11 ((2458281j,0s,0n),+0s,2299161j)>, price=3.266>...]
series.latest_price
#=> 3.234

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/taylorstib/eia_fuel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the EiaFuel project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.