# Fuel Price – US Gas & Diesel Prices (`data_wiki/fuel-price`) Actor

Get today's average US gas and diesel prices for the nation, any state, metro, city or ZIP code. See change vs yesterday, last week, last year, record highs and cheapest-state rankings. Great for fleets, travel planning, journalists and price tracking.

- **URL**: https://apify.com/data_wiki/fuel-price.md
- **Developed by:** [Data WiKi](https://apify.com/data_wiki) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### Fuel Price — US Gas & Diesel Averages, Trends, Rankings

Fuel Price collects today's average US gas and diesel prices for the nation, any state, metro area, ZIP code or city. Each row carries the current price, yesterday, last week, last month and last year, the change in dollars and percent, the record-high price and a rising / falling / stable trend. Optional extras add every metro area of a state, a cheapest-state ranking across all 51 states, and weekly price history back to 1990. Every response is structured JSON — ready to pass directly to an LLM, index into a vector store, or feed a price-monitoring pipeline. No login, cookies or API key needed. Run it daily to track where pump prices are heading next.

#### Why choose Fuel Price?

- **Averages, not guesses** — official daily averages with the date they were published on every row.
- **One input, many places** — mix `US`, states, ZIP codes and cities in one run; duplicates are merged.
- **Context built in** — change versus yesterday / week / month / year, record high, gap to the national and state average.
- **Live results** — rows appear in the Output tab while the run is still going, split into separate tables per section.

#### Key features

- National, state and metro fuel price averages for regular, midgrade, premium, diesel and E85
- ZIP code and city lookup that finds the right state and metro area
- Weekly fuel price history, last N weeks or everything since 1990
- Cheapest-state ranking for all 51 states (50 + DC)
- Prices in US dollars per gallon or per liter
- Starts without a proxy and switches to a stronger one on its own when a request is refused

#### Input

```json
{
  "urls": ["US", "NY", "11507", "Texas"],
  "fuel_types": ["regular", "diesel"],
  "include": ["metros", "history"],
  "history_weeks": 26,
  "price_unit": "gallon",
  "proxyConfiguration": { "useApifyProxy": false }
}
```

| Field | What it does |
|---|---|
| 📍 `urls` (required) | One location per line: `US`, a state code or name, a 5-digit ZIP code, or a city such as `Austin, TX`. |
| ⛽ `fuel_types` | `regular`, `midgrade`, `premium`, `diesel`, `e85` or `all`. E85 is published for the whole US only. |
| 🧭 `include` | `metros` (every metro area of each state location), `history` (weekly series), `all_states` (a row per state with its rank). |
| 📈 `history_weeks` | Weeks of history per series when `history` is on; `0` returns everything since 1990. |
| 💵 `price_unit` | `gallon` or `liter`. |
| 🌐 `proxyConfiguration` | Optional. No proxy by default. |

#### Output

Every price, history and error row goes to the default dataset and to a table for its section; the locations table shows how each input was understood. Tables: **national**, **states**, **metros**, **history**, **locations** (how each input was understood) and **errors**.

```json
{
  "record_type": "average",
  "scope": "state",
  "query": "Texas",
  "location": "Texas",
  "state_code": "TX",
  "fuel_type": "regular",
  "price_unit": "USD/gal",
  "price_current": 3.7105,
  "change_1w_pct": -1.73,
  "trend_1w": "falling",
  "record_high_price": 5.0,
  "state_rank_cheapest": 3,
  "states_total": 51,
  "price_date": "2026-10-27"
}
```

Average rows hold the price columns above plus `price_yesterday`, `price_week_ago`, `price_month_ago`, `price_year_ago`, `change_*`, `record_high_date`, `pct_below_record`, `vs_national` and `vs_state`. History rows hold `week_ending`, `price`, `change_vs_prior_week` and the area the series describes. When no state series exists for a fuel, the row shows a regional series and says so in `note`.

A test run with `US`, `NY`, `11507`, `Texas`, regular and diesel, metros and 8 weeks of history returned 140 rows: 92 price averages and 48 weekly rows.

#### 🚀 How to use (Apify Console)

1. Log in at https://console.apify.com and open **Actors**.
2. Open Fuel Price.
3. Enter your locations, pick fuels and extras.
4. Click **Start** and watch the log.
5. Open the **Output** tab, then export to JSON, CSV or Excel.

#### 🤖 Use via API / MCP

```bash
curl -X POST "https://api.apify.com/v2/actors/<ACTOR_ID>/runs" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"urls":["US","Texas"],"fuel_types":["regular"]}'
```

To call it from an AI agent, add the Apify MCP server: `claude mcp add --transport http apify "https://mcp.apify.com"`. The agent finds this Actor through the server's search, details and call tools.

#### Best use cases

- Daily pump-price monitoring for a state or city
- Fleet and logistics fuel budgeting with diesel trends
- Journalists and analysts comparing states against the record highs
- Dashboards and alerts on weekly price moves

#### Pricing

Each saved price or history row is one billable result. Error rows are not billed. Free plan runs return up to 10 results.

#### Frequently asked questions

**Does it return single gas stations?** No. It returns averages for the nation, states, metro areas and the metro that matches a ZIP code or city.

**Which places are supported?** US locations only: the nation, the 50 states, DC, ZIP codes and cities.

**How fresh is the data?** Averages are published daily; every row shows its `price_date`. Weekly history updates once a week.

**Why is a metro area missing for my ZIP code?** If no metro area matches the place, the row shows the state average and says so in `note`.

**Why does a history row say "regional"?** Some states have no weekly series of their own for a fuel, so the matching region is shown and labelled.

**What if the page layout changes?** The Actor reports the problem as an error row instead of returning silent empty results.

**Is a proxy needed?** No. It starts without one and switches automatically if a request is refused.

#### Support and feedback

Found a bug or need another field? Open an issue from the Actor page in Apify Console.

#### Legal

Only publicly available data is collected. You are responsible for using it in line with applicable laws and the terms of the data publishers.

# Actor input Schema

## `urls` (type: `array`):

One per line: US (national), a state code or name (NY, Texas), a 5-digit ZIP code (11507) or a city (Austin, TX). Duplicates are merged and every location returns its own rows.

## `fuel_types` (type: `array`):

Which fuels to return. Choose All for every fuel. E85 is published for the whole US only, so it appears on US rows.

## `include` (type: `array`):

Metro areas adds every metro area of each state location. Weekly history adds the weekly price series. All 51 states adds a row for every state with its cheapest-state rank.

## `history_weeks` (type: `integer`):

How many recent weeks of history to return when Weekly history is on. Use 0 for everything since 1990.

## `price_unit` (type: `string`):

Return prices in US dollars per gallon or per liter.

## `proxyConfiguration` (type: `object`):

By default no proxy is used. If a request is refused, the Actor switches to a stronger proxy automatically and keeps using it.

## Actor input object example

```json
{
  "urls": [
    "US",
    "NY",
    "11507",
    "Texas"
  ],
  "fuel_types": [
    "all"
  ],
  "include": [],
  "history_weeks": 10,
  "price_unit": "gallon",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Every row, price averages view.

## `national` (type: `string`):

National average prices.

## `states` (type: `string`):

State prices and rankings.

## `metros` (type: `string`):

Metro-area prices.

## `history` (type: `string`):

Weekly price series.

## `locations` (type: `string`):

How each input location was understood.

## `errors` (type: `string`):

Locations or series that failed.

## `summary` (type: `string`):

Counts and timing of the run.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "US",
        "NY",
        "11507",
        "Texas"
    ],
    "history_weeks": 10,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("data_wiki/fuel-price").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [
        "US",
        "NY",
        "11507",
        "Texas",
    ],
    "history_weeks": 10,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("data_wiki/fuel-price").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "US",
    "NY",
    "11507",
    "Texas"
  ],
  "history_weeks": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call data_wiki/fuel-price --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data_wiki/fuel-price"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WAgVA8TIfBjID589A/builds/rYe5bn18ubziaQao0/openapi.json
