# Gas prices API for US stations

> Live US gas prices. Parsed JSON. One flat-rate call.

- Endpoint: `POST https://scrapenest.dev/v1/scrape/gas-prices`
- Price: 10 credits
- Category: Site-specific
- Reference: https://scrapenest.dev/docs#ep-gas-prices
- Web page: https://scrapenest.dev/catalog/gas-prices
- Updated: 2026-11-04

Live US fuel prices for any ZIP or city/state combination. Returns structured JSON with brand, address, price, reporter, freshness, and the state-level low/average, not HTML you still have to parse. Supports the five fuel grades: regular, midgrade, premium, diesel, and E85.

## The hard part

Public fuel-price listings are awkward to consume programmatically, and some markets sit behind a cookie banner. Other scraping APIs hand you raw HTML and an invoice for their AI extraction add-on. We ship clean, parsed JSON instead. One flat credit cost, one stable schema.

## Gas prices API: what you get

- All five fuel grades via `grade=regular|midgrade|premium|diesel|e85`.
- Structured station data: brand, sub-brand, station_id, address, city, state, price, reporter, freshness.
- State-level stats: lowest plus average (for grades other than regular, computed from the returned stations).
- Accepts a 5-digit ZIP, ZIP+4, `City, ST` (comma optional), `City, State`, or `lat,lng` (no separate geocoder call).
- 10 credits flat. Cache hits 1 credit. Failures don't bill.

## Gas prices API use cases

- **Fleet and route costs**: Look up diesel or regular prices for the ZIP codes along a route and pick where to fill up.
- **Price comparison features**: Show nearby stations with brand, address, price and how fresh each reported price is.
- **Regional price tracking**: Store the `region_stats` lowest and average prices for a state over time.

## Gas prices API quickstart

Install an SDK with `pip install scrapenest` or `npm install scrapenest`, or call the HTTP API directly with your key in the `Authorization: Bearer` header. No key yet? Sign up free at https://scrapenest.dev/signup, verify your email, then create a key in your dashboard.

### Python SDK

```python
import os
from scrapenest import Client

client = Client(os.environ["SCRAPENEST_API_KEY"])
res = client.gas_prices("37122", grade="regular", limit=20)
for s in res.stations[:5]:
    print(s.brand, s.address, s.price, s.updated_relative)
if res.region_stats:
    print(res.region_stats.region, res.region_stats.lowest_price, res.region_stats.average_price)
```

### Node SDK

```javascript
import { ScrapeNest } from "scrapenest";

const client = new ScrapeNest({ apiKey: process.env.SCRAPENEST_API_KEY });
const res = await client.gasPrices({ location: "37122", grade: "regular", limit: 20 });
for (const s of res.stations.slice(0, 5)) console.log(s.brand, s.address, s.price, s.updated_relative);
if (res.region_stats) console.log(res.region_stats.region, res.region_stats.average_price);
```

### curl

```bash
curl -X POST https://scrapenest.dev/v1/scrape/gas-prices \
  -H "Authorization: Bearer sn_••••" \
  -H "Content-Type: application/json" \
  -d '{
        "location": "37122",
        "grade": "regular"
      }'
```

### Python (httpx)

```python
import httpx

r = httpx.post(
    "https://scrapenest.dev/v1/scrape/gas-prices",
    headers={"Authorization": "Bearer sn_••••"},
    json={"location": "37122", "grade": "regular"},
    timeout=60,
)
body = r.json()
print(body["stations"][0]["brand"], "$" + str(body["stations"][0]["price"]))
```

### JavaScript (fetch)

```javascript
const r = await fetch(
  "https://scrapenest.dev/v1/scrape/gas-prices",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sn_••••",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ location: "37122", grade: "regular" }),
  },
);
const { stations, region_stats } = await r.json();
```

### Go

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]any{
        "location": "37122",
        "grade":    "regular",
    })
    req, _ := http.NewRequest("POST",
        "https://scrapenest.dev/v1/scrape/gas-prices",
        bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer sn_••••")
    req.Header.Set("Content-Type", "application/json")
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    var out map[string]any
    json.NewDecoder(resp.Body).Decode(&out)
    fmt.Println(out["stations"])
}
```

## Gas prices API request and response

### Request body

```json
{
  "location": "37122",
  "grade": "regular",
  "limit": 20
}
```

### Response

```json
{
  "location": {
    "query": "37122",
    "zip": "37122",
    "city": "Mount Juliet",
    "state": "TN"
  },
  "grade": "regular",
  "stations": [
    {
      "brand": "Kroger",
      "sub_brand": "Kroger Fuel Center",
      "station_id": "21847",
      "address": "401 S Mt Juliet Rd",
      "city": "Mount Juliet",
      "state": "TN",
      "price": 2.79,
      "currency": "USD",
      "unit": "USD/gallon",
      "reporter": "anon_18234",
      "updated_relative": "37 Minutes Ago"
    }
  ],
  "region_stats": {
    "state": "TN",
    "region": "Tennessee",
    "region_type": "state",
    "lowest_price": 2.69,
    "average_price": 2.95
  },
  "source_url": "https://scrapenest.dev",
  "fetched_at": "2026-05-19T14:30:00Z",
  "took_ms": 4823,
  "cache_hit": false,
  "credits_charged": 10
}
```

Fields with no value are left out of the JSON rather than sent as `null`, so read optional fields defensively.

## Gas prices API pricing

10 credits flat. Cache hits bill at 1 credit. The cache TTL defaults to 10 minutes (prices change slowly); override via `cache_ttl_seconds` up to 1 hour.

- Pricing freshness is reporter-driven: stations update every few minutes to several hours. The `updated_relative` field on each station tells you how stale that specific price is.
- Stations without a reported price for the requested grade are omitted from the response (the source shows them as `- - -`).

## Gas prices API limits

- `location`: 2 to 200 characters: a ZIP or ZIP+4, `City, ST`, `City, State`, a bare city or `lat,lng`.
- `limit`: 1 to 50 stations, default 20. Listings typically surface about 13.
- `grade`: `regular` (default), `midgrade`, `premium`, `diesel` or `e85`.
- Cache: 10 minutes by default, up to 1 hour with `cache_ttl_seconds`.
- US locations only. A lookup that returns no stations bills 0 credits.

## Gas prices API error codes

| HTTP | Code | Meaning |
| --- | --- | --- |
| 422 | `validation_error` | The location can't be resolved to a US place, or `grade` isn't one of the five. |
| 503 | `upstream_fetch_failed` | The price source couldn't be reached. Not billed; retry once with backoff. |

Every endpoint can also return `401 unauthorized` (missing or wrong key), `402 insufficient_credits` (balance used up), `403 email_not_verified` (an email signup must verify its address before its key works) and `429 rate_limited` or `concurrency_limit_exceeded`. All errors share one JSON envelope; see the [error reference](https://scrapenest.dev/docs#errors).

## Gas prices API FAQ

### How do I get gas prices by ZIP code?

POST a 5-digit ZIP as the location and you get back the stations near it with their current per-gallon price, brand, and street address as JSON. The endpoint also accepts ZIP+4, "City, ST", "City, State", and "lat,lng", so you don't need to run a geocoder first.

### Is there a free gas prices API?

You can call this one on the free tier: every account starts with 1,000 credits a month and no card, and a gas-price lookup costs 10 credits (1 on a cache hit). That's roughly 100 fresh lookups a month before you pay anything.

### Which fuel grades are available?

All five: regular, midgrade, premium, diesel, and E85. Pass the one you want as `grade`. Stations that haven't reported a price for that grade are left out of the response rather than returned with a null price.

### How current are the prices?

Prices are crowd-reported, so freshness varies by station — anywhere from a few minutes to several hours old. Every station carries an `updated_relative` field so you can see exactly how stale that specific price is and drop anything past your own threshold.

### Do I get state or regional averages too?

Yes, when the source publishes them. For regular, `region_stats` carries the source's regional lowest and average price. The source's regional figures cover regular only, so for other grades they are computed from the returned stations of that grade (with a `note` saying so) and omitted when none reported a price.

## Related endpoints

- [Google Maps Reviews API](https://scrapenest.dev/catalog/maps-reviews.md): `POST /v1/scrape/google-maps/reviews`. Author, rating, text, posted_at, photos, owner reply. Structured JSON, newest first.
- [Web scraping API for any URL](https://scrapenest.dev/catalog/scrape-url.md): `POST /v1/scrape/url`. Point us at a page. We get past the wall and hand back the rendered HTML and clean text.
- [SERP API for multi-engine web search](https://scrapenest.dev/catalog/search.md): `POST /v1/search`. Multi-engine web search aggregated and re-ranked into one feed.

## Get 1,000 free credits

Every account starts on the Free plan: 1,000 credits a month, no card. Verify your email, then mint an API key and make this call. Sign up at https://scrapenest.dev/signup.
