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
Built Distribution
Hashes for uk_fuel_prices_api-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67c04f0961b94de9ad0db58b6aafd038ded4c192db424ac700974d89f37c094c |
|
MD5 | a9d22518b5fc3bf54091bf5dd6e27624 |
|
BLAKE2b-256 | af025c0481c390026b14b1b29344649031485b5269dfc979f857dd4cb19a546a |