How It Works

A transparent look at how we collect prices, power the map, and handle your data.

Step 1 — Collecting Gas Price Data

Our backend server runs a scheduled job every hour that calls a Canadian fuel price API. This API aggregates price information from a mixture of commercial data partnerships and community-submitted reports across Canada.

For Calgary specifically, we query the API using a set of representative postal codes that cover Calgary's major districts — downtown core, NW, NE, SW, SE, and the airport corridor. This ensures we get broad coverage rather than just the stations closest to a single central point.

Each hourly batch updates our PostgreSQL database with the latest price for every station. If the API returns no data for a given run (due to a rate limit, network issue, or the API being temporarily down), we simply serve the most recently cached prices from our database and display the "last updated" timestamp on each station card so you know how fresh the data is.

Step 2 — Our Database

Station records are stored with their full address, geographic coordinates (latitude and longitude), brand, and price in cents per litre. When the API returns an existing station with a new price, we update only the price and timestamp — we don't create duplicate records.

In addition to live API data, we seed the database with a set of plausible-looking Calgary stations as a fallback. This means the site always shows somethinguseful even during API downtime. Seed prices are marked as illustrative only.

Step 3 — Serving the Data

Our API server (Node.js + Express) exposes a few simple JSON endpoints:

  • /api/stations/cheapest — returns the top 20 cheapest active stations in Calgary
  • /api/stations?lat=&lng=&radiusKm= — returns stations within a given radius of a coordinate, sorted by price then distance
  • /api/stations/:id — returns a single station's full detail

Distance filtering uses the Haversine formula, which gives accurate straight-line distances between two GPS coordinates without needing a full mapping engine on the server side.

Step 4 — The Map

The interactive map is powered by Leaflet, an open-source JavaScript mapping library, using OpenStreetMap tiles. OpenStreetMap is a community-maintained, royalty-free map dataset. No Google Maps API key or payment is required to display the map.

When stations are loaded, we place a marker pin at each station's GPS coordinates. Clicking a pin shows a small popup with the station name, current price, address, and a link to open directions in Google Maps.

If you share your location, a separate red dot marks where you are on the map, and the view automatically zooms to show the stations nearest to you.

Step 5 — Your Location

The "Nearest to Me" feature uses the browser's built-in navigator.geolocation API. This is a standard web API that asks your device's operating system for your GPS or Wi-Fi-based position. The browser shows you a permission prompt before sharing any location data.

Once you allow access, your latitude and longitude are sent to our API server only to query nearby stations. We do not log, store, or transmit these coordinates anywhere else. The request looks like:

GET /api/stations?lat=51.04&lng=-114.07&radiusKm=10

These coordinates travel over HTTPS (encrypted) and are used only to filter the station list in memory on our server. They are never written to a database or analytics log.

If you decline location access, you can still search by entering a Calgary postal code. We use a rough lookup table to convert the postal code prefix into approximate coordinates — accurate enough to find nearby stations, but not precise enough to identify your exact address.

Price Accuracy

We display prices as reported by our data source. In practice this means prices are usually within 1–3 cents of what you'll see at the pump, but they are not guaranteed to be exact. Prices can change multiple times a day, particularly when wholesale oil prices move sharply.

Always glance at the physical pump price before you start filling up. Our "last updated" timestamp on each station card tells you exactly when the price was last confirmed by our data source.

For more on accuracy and our data disclaimer, see the Disclaimer page.