Fuel Prices API

getFuelPrices

The getFuelPrices API provides refined fuel price data and reference data. Refined fuel data can be requested for fuel selling locations, for geographic coordinates and radius, for zip code and radius, and for a specified county. Refined fuel data can be filtered by product name(s), and by number of locations will be returned. Reference data contains fuel selling locations and product names, providing valid values in use for requesting refined fuel data. Reference data can be requested for geographic coordinates and radius. If no geographic coordinates are given, reference data will return all valid values by default.

All APIs

Contact Us to Get Access

By submitting this form you are opting in to receive email communications from Barchart for related product, service or company information, updates and announcements. You can unsubscribe at anytime. View our Privacy Policy.

Inputs

requestType optional

A type of reference data to define what reference data will be returned.

Type
enum (A type which includes a list of valid possible values.) 
Default
prices 

Valid Values:
products, locations, prices

location optional

A location id or a code identifies a or multiple fuel selling location(s) that fuel prices will be returned for. A valid code consist of multiple location ids separated by a comma, and the code can contain up to 100 locations. A list of valid location ids can be retrieved by using this API with input: requestType = location. location and several other inputs -geographic coordinates, zipCode, maxDistance, county, totalLocations- are mutually exclusive.

Type
list (A comma or semi-colon delimited string.) 

latitude optional

The latitude of a valid geographic coordinates to define the center of area that fuel prices will be returned for. Geographic coordinates and Zipcode are mutually exclusive.

Type
double (A numeric type defining a number with fractional parts. (example: 2.14)) 

longitude optional

The longitude of a valid geographic coordinates to define the center of area that fuel prices will be returned for. Geographic coordinates and Zipcode are mutually exclusive.

Type
double (A numeric type defining a number with fractional parts. (example: 2.14)) 

zipCode optional

A valid US or Canadian zip code to define the center of area that fuel prices will be returned for. Default value is 60606. Geographic coordinates and Zipcode are mutually exclusive.

Type
string (A sequence of characters. (example: GOOG)) 
Example
60606 
Default
60606 

maxDistance optional

A maximum distance from geographic coordinates input or from the center of zip code input in miles to help user define the area that fuel prices will be returned for. Maximum value is 250

Type
double (A numeric type defining a number with fractional parts. (example: 2.14)) 
Example
100 
Default
100 

county optional

A valid string code which represents the concatenation of county name and state code seperated by a hyphen.

Type
string (A sequence of characters. (example: GOOG)) 
Example
BOONE COUNTY-IA 

fipsCode optional

A string concatenation of state FIPS code and county FIPS code without separator to define the county that fuel prices will be returned for. Please click here to get a list of possible values.

Type
integer (A numeric type defining a whole number. (example: 2)) 
Example
17053 

productName optional

A standard product name or a name list that's separated by pipe (|) to filter prices. Note that the input needs to be encoded in UTF-8. A list of valid product names can be retrieved by using this API with input: requestType = products.

Type
list (A comma or semi-colon delimited string.) 
Example
USLD 

totalLocations optional

The maximum amount of fuel selling locations that fuel prices will be returned for. If zip code is set, then API will provide cashbid for given amount closet locations in relation to the requested zip code. Maximum value is 100.

Type
integer (A numeric type defining a whole number. (example: 2)) 
Example
Default
30 

page optional

The page number.

Type
integer (A numeric type defining a whole number. (example: 2)) 
Example
Default

fields optional

Additional as per-requested fields that the user can define. Requested fields should be separated by a comma. Valid per-requested fields are companyId, locationType, mailingAddress, fax, defLanes, dieselLanes, bioBlend, businessHours, productId, productShort, productFull

Type
list (A comma or semi-colon delimited string.) 

Outputs

Name / Requirement
Description
Type
prices
always returned
A list of fuel prices from a fuel selling location. Each fuel price contains the meta and price data applicable to that location.
enum
A type which includes a list of valid possible values.
distance
always returned
Distance of the fuel selling location in miles from the input zip code/geographic coordinates.
string
A sequence of characters. (example: GOOG)
locationId
always returned
A internal identifier of fuel selling location.
int
A numeric type defining a whole number. (example: 2)
location
always returned
Name of fuel selling location that fuel price originated from.
string
A sequence of characters. (example: GOOG)
companyId
as requested
A internal identifier of fuel selling company.
int
A numeric type defining a whole number. (example: 2)
company
always returned
A full-length name for companies.
string
A sequence of characters. (example: GOOG)
locationType
as requested
The type of fuel selling location.
string
A sequence of characters. (example: GOOG)
address
always returned
The street address of the location.
string
A sequence of characters. (example: GOOG)
mailingAddress
as requested
The mailing address of the location.
string
A sequence of characters. (example: GOOG)
highway
always returned
The nearby highway exit(s).
string
A sequence of characters. (example: GOOG)
zipCode
always returned
The zip code for the location.
string
A sequence of characters. (example: GOOG)
city
always returned
City that contains the applicable fuel price.
string
A sequence of characters. (example: GOOG)
county
always returned
The name of the county containing the applicable fuel price.
string
A sequence of characters. (example: GOOG)
fipsCode
always returned
A string concatenation of state FIPS code and county FIPS code to identify a county.
double
A numeric type defining a number with fractional parts. (example: 2.14)
state
always returned
2-char abbreviation of the state that contains the applicable fuel price.
string
A sequence of characters. (example: GOOG)
country
always returned
ISO-3 country code of the location.
string
A sequence of characters. (example: GOOG)
longitude
always returned
The longitude of the location.
double
A numeric type defining a number with fractional parts. (example: 2.14)
latitude
always returned
The latitude of the location.
double
A numeric type defining a number with fractional parts. (example: 2.14)
phone
always returned
The phone number for the location.
string
A sequence of characters. (example: GOOG)
fax
as requested
The fax number for the location.
string
A sequence of characters. (example: GOOG)
showers
always returned
The total number or availability of showers.
string
A sequence of characters. (example: GOOG)
truckSpaces
always returned
The total number or availability of truck parking spaces.
string
A sequence of characters. (example: GOOG)
defLanes
as requested
The total number or availability of DEF lanes.
string
A sequence of characters. (example: GOOG)
dieselLanes
as requested
The total number or availability of diesel lanes.
string
A sequence of characters. (example: GOOG)
weighScales
always returned
The brand or availability of weight scale.
string
A sequence of characters. (example: GOOG)
bioBlend
as requested
The type or availability of bio-blend fuel.
string
A sequence of characters. (example: GOOG)
businessHours
as requested
The operating hours for the location.
string
A sequence of characters. (example: GOOG)
currency
always returned
The currency used for the location.
string
A sequence of characters. (example: GOOG)
metric
always returned
The units system a location used for quoting.
string
A sequence of characters. (example: GOOG)
locationUpdateDate
always returned
Date when the meta data was last updated for a location in Central Time Zone.
date
A date in the format of YYYY-MM-DD.
lastUpdateTimestamp
always returned
Date that prices were last updated for a location in Central Time Zone.
dateTime
A date and time in the format of YYYY-MM-DD HH:MI:SS<TIMEZONE_OFFSET>.
productShort
as requested
A short-length name for products.
string
A sequence of characters. (example: GOOG)
product
as requested
A medium-length name for products.
string
A sequence of characters. (example: GOOG)
productFull
as requested
A full-length name for products.
string
A sequence of characters. (example: GOOG)
productDescription
as requested
A short description for the product.
string
A sequence of characters. (example: GOOG)

Status Code Responses

200
OK
Success
400
Bad Request
The request was invalid, please see the message for more information.
500
Internal Server Error
Something is not working correctly, please contact support.




PHP

<?php

$ondemand = new SoapClient('https://ondemand.websol.barchart.com/service?wsdl');

$params = [
    'apikey' => 'YOUR_API_KEY',
    'latitude' => '',
    'longitude' => '',
    'zipCode' => '60606',
    'maxDistance' => '100',
    'county' => 'BOONE COUNTY-IA',
    'fipsCode' => '17053',
    'productName' => 'USLD',
    'page' => '1',
];

$result = $ondemand->getFuelPrices($params);
var_dump($result);

Classic ASP

Dim ondemand
Dim result

Set ondemand = Server.CreateObject("MSSOAP.SoapClient30")
ondemand.ClientProperty("ServerHTTPRequest") = True
ondemand.MSSoapInit("https://ondemand.websol.barchart.com/service?wsdl")

Set result = ondemand.getFuelPrices("YOUR_API_KEY", "", "", "60606", "100", "BOONE COUNTY-IA", "17053", "USLD", "1")

Perl

use SOAP::Lite;
use SOAP::WSDL;

my $ondemand = SOAP::Lite
    -> service('https://ondemand.websol.barchart.com/service?wsdl');

my $result = $ondemand->getFuelPrices('YOUR_API_KEY', '', '', '60606', '100', 'BOONE COUNTY-IA', '17053', 'USLD', '1');

print $result;

Python

from suds.client import Client
ondemand = Client('https://ondemand.websol.barchart.com/service?wsdl')

result = client.service.getFuelPrices('YOUR_API_KEY', '', '', '60606', '100', 'BOONE COUNTY-IA', '17053', 'USLD', '1')

print result

Ruby

require 'savon'

ondemand = Savon.client(wsdl: 'https://ondemand.websol.barchart.com/service?wsdl')

response = ondemand.call(
    :getFuelPrices,
    message: {
        apikey: 'YOUR_API_KEY',
        latitude: '',
        longitude: '',
        zipCode: '60606',
        maxDistance: '100',
        county: 'BOONE COUNTY-IA',
        fipsCode: '17053',
        productName: 'USLD',
        page: '1',
    }
)

response.body