Skip to content
Tech News
← Back to articles

Tracking Costco gas prices

read original more articles
Why This Matters

This article highlights a personal project tracking Costco gas prices during a regional fuel crisis, revealing insights into how gas prices fluctuate and Costco's pricing strategy as a loss leader. It underscores the potential for data-driven approaches to understand retail pricing trends and consumer decision-making in the absence of centralized information.

Key Takeaways

All views and content published are my own and do not represent any current or former employer. This site is maintained in a personal capacity. Technical content is shared for educational purposes only.

TL;DR: I tracked gas prices at 600 Costco warehouses during the Strait of Hormuz fuel crisis and mapped out how they changed.

Back in April, I lived almost exactly between two Costco warehouses, and for years I ran the same mental math every time I needed gas: which of the two was actually cheaper that week.

Unfortunately, Costco doesn't publish gas prices anywhere centrally. The official site buries them on individual warehouse pages, and my two nearest warehouses were rarely priced the same. Costco gas is famously a loss leader, typically running 15 to 20 cents below surrounding stations. That gap is usually enough to make the detour worth it, though not enough to make the choice between my two Costcos obvious.

As a commuter in Tampa, a sprawling city with almost no public transportation, I got a lot more conscious of where I filled up as gas prices climbed that spring. I started getting curious about Costco's prices specifically: were they climbing at the same rate as other gas stations, and could Costco realistically keep running gas as a loss leader if prices kept rising?

There was no good way to see that trend historically. So naturally, I built one.

Guzzling the Gas Data

Unfortunately, this was probably the easiest part of the project. I wish I had a cool reversing method to talk about like the Waffle House story, but Costco gave me very little resistance in collecting this data.

My first find when I started digging through Costco's site was AjaxGetGasPricesService , an endpoint that takes an input of warehouse IDs formatted as ID1_ID2_ID3_ID4 . Underscores as an array delimiter is an interesting choice! It was useful, but not quite what I wanted; I needed the location data for each warehouse so I could map them out and figure out which was actually shorter to drive to.

Digging a little further surfaced exactly what I needed: AjaxWarehouseBrowseLookupView . Much like the name suggests, the function looks up warehouses using a latitude and longitude parameter input. Even better, the parameter populateWarehouseDetails stuffs the response with just about every piece of information you could want about a Costco: address, hours, services, food court availability (!!), and most importantly, gas prices.

... continue reading