Description
This python package is a simple API wrapper around the EIA weekly US diesel prices API.
Installation
pip install dieselprices
How it works
When passing in week arguments, note that it must be in the YYYYMMDD form. Additionally, the date must be a Monday as EIA sets prices based on a Monday date.
You must first set your key. You can get an API key at https://www.eia.gov/opendata/register.php
import dieselprices
dieselprices.key('YOUR_KEY')
To get the current week's diesel price (if EIA has set it yet), just create a Prices instance with no arguments. Then call the get_price() method.
p1 = dieselprices.Prices()
price = p1.get_price()
To get a price for a week in the past, pass in a date on the week argument.
p2 = dieselprices.Prices(week=20171106)
p2.get_price()
To get a series of prices for multiple dates, pass in a list of dates on the weeks argument. The result on the get_price method will be a list of tuples. Each tuple having the week and price.
p3 = dieselprices.Prices(weeks=[20171106, 20171030])
p3 = get_price()