Skip to main content

Python API to access latest fuel prices in the UK

Project description

UK Fuel Prices

Pull UK Fuel Price data from sources listed here. Please note the data is not complete, and does not include pricing for every fuel station in the UK. More information is available at the link.

Installation

The package is available to install with pip

pip install uk-fuel-prices-api

Example

Initialise

Import the package, and retrieve price information. get_prices() should be called whenever you want to update the pricing data. Please bear in mind that at this time, most companies are only updating their data feeds every 24 hours.

from uk_fuel_prices_api import UKFuelPricesApi
api = UKFuelPricesApi();

await api.get_prices()

Search

Search for all stations matching value

await api.search("searchstring")

# Only return first 5 results
await api.search("searchstring", 5)

Site ID

Get single Station by known site_id

station = await api.get_site_id("siteid")

Nearest

Get n stations nearest to lat lnt point

lat, lng = 53.743175, -1.882085  # Halifax Esso
nearest_stations = api.nearestN(lat, lng)

Stations Within a Given Radius

Get all fuel stations within a radium (in km) of lat lng pt

lat, lng = 53.743175, -1.882085  # Halifax Esso
radius = 5

stations = api.stationsWithinRadius(lat, lng, radius)

Sort Stations by Price

Sort list of stations by price.

Currently fuel_type should be

  • "E10" (petrol)
  • "E5" (petrol)
  • "B7" (diesel)
  • "SDV" (super-grade diesel)
# Get some stations
lat, lng = 53.743175, -1.882085
radius = 10
stations = api.stationsWithinRadius(lat, lng, radius)

# Sort by E10 price
fuel_type = "E10"
sorted_stations = api.sortByPrice(stations, fuel_type)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uk_fuel_prices_api-0.0.5.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uk_fuel_prices_api-0.0.5-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file uk_fuel_prices_api-0.0.5.tar.gz.

File metadata

  • Download URL: uk_fuel_prices_api-0.0.5.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for uk_fuel_prices_api-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7ef173e6da514b6e5ba69aee6ac307c6f5ab7ea07a2561ee3fd545e97f2d393a
MD5 ba543b964df25fbd051d40c8087f87fc
BLAKE2b-256 7dc1c1bce61c2bc684f2d0717efbb5159aad40e2559a882050d24cc79db0176b

See more details on using hashes here.

File details

Details for the file uk_fuel_prices_api-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for uk_fuel_prices_api-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 89c52c2bb16ca8fa28d76672157ffe8770a52049f9d605a1bd8e4b3a60229da2
MD5 3b9d1ea37f828bcd0890f1e1d690ba14
BLAKE2b-256 0120739ef36ebe7c7a3dd5df1082d66f4359f569484f72df41101d823f209c4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page