# US Gas Stations Scraper (`eneiromatos/us-gas-stations-scraper`) Actor

Scrape detailed information about US gas stations. Target specific locations by city and state, or provide a list of Google Maps Place IDs. Extracts name, gas prices, address, phone number, operating hours, and more.

- **URL**: https://apify.com/eneiromatos/us-gas-stations-scraper.md
- **Developed by:** [Eneiro Matos](https://apify.com/eneiromatos) (community)
- **Categories:** Lead generation, Travel, Automation
- **Stats:** 11 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## US Gas Stations Scraper

An efficient and powerful Apify actor for scraping detailed information about US gas stations. This scraper allows you to target specific geographic locations or a list of known Google Maps Place IDs. It extracts crucial data including fuel prices, addresses, contact information, and operating hours, providing a comprehensive dataset for market analysis, location intelligence, and other data-driven applications.

### Features

- **Targeted Scraping**: Scrape by city and state, or provide a specific list of Google Maps Place IDs.
- **Comprehensive Data Extraction**: Gathers essential details like name, address, phone number, gas prices (Regular, Midgrade, Premium, Diesel), website, operating hours, and user reviews.
- **Proxy Integration**: Built-in support for Apify Proxy to ensure reliable and anonymous scraping.
- **Structured Output**: Provides data in a clean, well-structured JSON format for easy integration with other systems.
- **Scalable**: Built on the Apify platform, allowing you to scale your scraping jobs to any size.

### Input Parameters

To run the scraper, you need to provide input settings. You can do this via the Apify Console UI or by using the API.

| Field           | Type      | Description                                                                                                           |
| --------------- | --------- | --------------------------------------------------------------------------------------------------------------------- |
| `placeIds`      | `Array`   | An array of Google Maps Place IDs to scrape directly. E.g., `["ChIJP3ODowq7QIYRsEPAu4jkeP8"]`                         |
| `stateCode`     | `String`  | A two-letter US state code (e.g., "TX", "CA") to search for gas stations within that state.                           |
| `cityName`      | `String`  | The name of the city to scrape within the specified state.                                                            |
| `useApifyProxy` | `Boolean` | Set to `true` to use Apify Proxy for the requests, which is recommended for any serious scraping. Defaults to `true`. |

**Example Input:**

```json
{
    "stateCode": "TX",
    "cityName": "Houston",
    "useApifyProxy": true
}
```

```json
{
    "placeIds": ["ChIJP3ODowq7QIYRsEPAu4jkeP8"],
    "useApifyProxy": true
}
```

### Output Data Structure

The scraper returns a dataset of gas stations with the following structure. Each item in the dataset represents a single gas station.

```json
{
    "itemUrl": "https://www.google.com/maps/place/Pilot+Travel+Center/@29.8002384,-95.2676262,17z/data=!3m1!4b1!4m6!3m5!1s0x8640bb0aa383733f:0xff78e488bbc043b0!8m2!3d29.8002384!4d-95.2676262!16s%2Fg%2F1tj33h_0?entry=ttu&g_ep=EgoyMDI1MDgxMi4wIKXMDSoASAFQAw%3D%3D",
    "IdCodes": {
        "CID": "18408714752793527216",
        "PID": "ChIJP3ODowq7QIYRsEPAu4jkeP8",
        "FID": "0x8640bb0aa383733f:0xff78e488bbc043b0"
    },
    "mainImage": "https://lh3.googleusercontent.com/p/AF1QipMmll2Rl8y-wAu42X1IdPhNNDxKJlhxmoPGFnAH=w408-h321-k-no",
    "imageCount": "",
    "name": "Pilot Travel CenterSponsoredBy Pilot Travel Center",
    "gasPrices": [
        {
            "price": 2.54,
            "type": "Regular",
            "currency": "USD",
            "measureUnit": "gallon"
        },
        {
            "price": 3.14,
            "type": "Midgrade",
            "currency": "USD",
            "measureUnit": "gallon"
        },
        {
            "price": 3.52,
            "type": "Premium",
            "currency": "USD",
            "measureUnit": "gallon"
        },
        {
            "price": 3.5,
            "type": "Diesel",
            "currency": "USD",
            "measureUnit": "gallon"
        }
    ],
    "website": "https://locations.pilotflyingj.com/us/tx/houston/4440-north-mccarty-street",
    "bookingUrl": "",
    "phoneNumber": "+17136753375",
    "address": {
        "address": "4440 N McCarty St",
        "city": "Houston",
        "state": "TX",
        "zipCode": "77013",
        "plusCode": "RP2J+3W El Dorado / Oates Prairie, Houston, TX",
        "coordinates": {
            "lat": "29.8002384",
            "long": "-95.2676262"
        }
    },
    "language": "English",
    "categories": ["Truck stop", "Convenience store", "Gas station"],
    "services": ["Onsite services", "Wheelchair accessible restroom"],
    "reviewStats": {
        "rating": "3.5",
        "reviewsCount": "",
        "reviewsDistribution": {
            "oneStars": "648",
            "twoStars": "351",
            "threeStars": "245",
            "fourStars": "108",
            "fiveStars": "324"
        }
    },
    "openHours": {
        "Thursday": "Open 24 hours",
        "Friday": "Open 24 hours",
        "Saturday": "Open 24 hours",
        "Sunday": "Open 24 hours",
        "Monday": "Open 24 hours",
        "Tuesday": "Open 24 hours",
        "Wednesday": "Open 24 hours"
    },
    "isTempClosed": false,
    "isPermClosed": false
}
```

### How to Run

1. Create a new task for this actor.
2. Set the input parameters as described above.
3. Click "Start" to run the actor.
4. When the run is finished, you can download the results from the "Dataset" tab in either JSON or other formats.

# Actor input Schema

## `placeIds` (type: `array`):

An array of Google Maps Place IDs to scrape.

## `stateCode` (type: `string`):

Two-letter US state code.

## `cityName` (type: `string`):

Name of the city to scrape.

## `useApifyProxy` (type: `boolean`):

Whether to use Apify Proxy.

## Actor input object example

```json
{
  "placeIds": [
    "ChIJFwEAAN2-QIYRpYd_Mq-d8II"
  ],
  "useApifyProxy": true
}
```

# 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 = {
    "placeIds": [
        "ChIJFwEAAN2-QIYRpYd_Mq-d8II"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("eneiromatos/us-gas-stations-scraper").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 = { "placeIds": ["ChIJFwEAAN2-QIYRpYd_Mq-d8II"] }

# Run the Actor and wait for it to finish
run = client.actor("eneiromatos/us-gas-stations-scraper").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 '{
  "placeIds": [
    "ChIJFwEAAN2-QIYRpYd_Mq-d8II"
  ]
}' |
apify call eneiromatos/us-gas-stations-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eneiromatos/us-gas-stations-scraper"
        }
    }
}
```

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/fzXHAdApBswwkl3UC/builds/5fAvrSb8PLAeNkesF/openapi.json
