Fuel API

The Fuel API provides queries and events for interacting with the services that comprise it. 

Calculations

The Fuel API calculates values like distance between fillups and MPG using a very simply formula that always assumes that fillups are recorded in sequence. It doesn't try to recalculate sequences based on entered timestamps.

Units

The Fuel API is unitless. It depends on the developer to consistently record the same units for the application.

Return Results

The Fuel API returns fuel details. A fillup record contains the following data fields

NameTypeCalculatedDescription
idIntegeryesThe internal system identifier for this trip. Uses time the record is created as key.
timestampDateTime The time of the purchase. Can be given or calculated.
volumeFloatnoVolume of the fillup
unit_priceFloatnoprice for a unit of fuel
costFloatyesTotal cost of the fillup
locationStringnoThe location of the fillup
odometerFloat  no

Odometer reading at fillup

distanceFloatyesDistance between this fillup and the last
mpgFloatyesDistance per fuel unit based on distance
intervalIntegeryesSeconds between this fill up and the last

DateTime is an ISO8901 formatted time. Returned times are always UTC

 

Queries

 

The query domains for the Fuel API are
developmentb16x20
productionfuse_fuel

The production version is always pre-pended to the production query domain with a underbar, so for version 1 of the API would use v1_fuse_fuel as the query domain. In this document we will use the production query domain without the version. See Fuse Base URLs for more information on how to turn the descriptions shown here into a query URL. 

fuse_fuel:fillups([<id>])

Query fillups. All parameters are optional. With <id>, the detailed fillup data for a specific fillup is returned. Without <id>, detailed data for the last fillup is returned.

For example, to return the ten most recent fillups, you would simply for the following:

fuse_fuel:fillups()

To return the data for last fillup:

fuse_fuel:fillups()

fuse_fuel:fillupsByDate(<start>, <end>)

Query past fillups for those between a start and end time. Summary fillup data is returned. Times are expressed in ISO8901 format.

For example to find all the fillups for June 2014 in the US Mountain time zone:

fuse_fuel:fillupsByDate(start="20140601T000000-0600", end="20140701T000000-0600")

Events

The following events are used defined for fillups in the Fuse API.

fuse:new_fuel_purchase

A new fillup has been detected with the following attributes:

NameTypeDescription
volumeFloatVolume of the fuel purchase
unit_priceFloatprice for a unit of fuel
locationStringThe location of the fuel purchase
odometerFloat  

Odometer reading at fuel purchase

when_boughtDateTimeTime when fuel was purchase

fuse:updated_fuel_purchase

An updated fillup has been detected with the following attributes:

NameTypeDescription
idDateTimeid for the record to update
volumeFloatVolume of the fuel purchase
unit_priceFloatprice for a unit of fuel
locationStringThe location of the fuel purchase
odometerFloat  

Odometer reading at fuel purchase

when_boughtDateTimeTime when fuel was purchase

fuse:unneeded_fuel_purchase

Delete the fuel purchase record with the given id.

NameTypeDescription
idDateTimeid for the record to delete

Services

The following services operate in the Fuel API

fuse_fuel:record_fuel_purchase

Selector:

select when fuse new_fuel_purchase

Synopsis:

Records a new fuel purchase.  Uses fuse_fuel:update_fuel_purchase

Raises:

fuse:updated_fuel_purchase

fuse_trips:update_fuel_purchase

Selector:

select when fuse updated_fuel_purchase

Synopsis:

Updates a fuel purchase. 

Raises:

none

fuse_trips:delete_fuel_purchase

Selector:

select when fuse unneeded_fuel_purchase

Synopsis:

Deletes the fuel purchase for a given ID  

Raises:

none