# Local Business Data Extractor (NAP, hours, geo) (`tom2turnt/localbusiness-extractor`) Actor

Extract normalized local-business data — name, type, phone, email, full address, lat/long, opening hours, price range, rating — from public pages via JSON-LD (LocalBusiness subtypes, Organization), microdata, and OpenGraph. HTML-only, fast, structured ok/error output.

- **URL**: https://apify.com/tom2turnt/localbusiness-extractor.md
- **Developed by:** [Tommy G](https://apify.com/tom2turnt) (community)
- **Categories:** Integrations, Lead generation, Jobs
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, NaN 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/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Local Business Extractor (Apify Actor)

Give it any public **business / venue page URL** and get back clean, normalized
**LocalBusiness** data — name, business type, contact details, full address with geo
coordinates, opening hours, price range, and aggregate rating — pulled from schema.org
`LocalBusiness` (and subtypes like Restaurant / Store) in JSON-LD and microdata. HTML-only
(no headless browser) so it's fast and cheap. Ideal for **local-business directories, lead
lists, and store-locator / map datasets**.

### What it extracts
For each page it returns one flat record with:

- **name**, **legal_name**, **business_type**, **description**
- **telephone**, **email**, **url**, **image**
- Address: **street_address**, **locality**, **region**, **postal_code**, **country**, **address_full**
- Geo: **latitude**, **longitude**
- **opening_hours[]**, **price_range**, **founding_date**, **same_as[]** (linked social/profile URLs)
- Ratings: **rating_value**, **rating_best**, **rating_count**

Plus control keys present on **every** row (ok and error alike, for clean buyer tables):
`status, requested_url, final_url, http_status, redirected, found, complete, page_type,
source, render_required, fields_found, error, extracted_at`.

### Input
```json
{ "startUrls": [{ "url": "https://example.com/locations/downtown" }], "maxConcurrency": 5, "maxPages": 100 }
````

`maxPages` capped at 200, `maxConcurrency` at 20 (cost guard).

### Output — one STABLE record per URL (ok *and* error rows share the shape)

```json
{
  "status": "ok",
  "requested_url": "https://example.com/locations/downtown",
  "final_url": "https://example.com/locations/downtown",
  "http_status": 200,
  "found": true,
  "complete": true,
  "page_type": "localbusiness",
  "source": "json-ld",
  "name": "Acme Coffee Downtown",
  "legal_name": "Acme Coffee LLC",
  "business_type": "CafeOrCoffeeShop",
  "description": "Specialty coffee in the heart of downtown.",
  "telephone": "+1-212-555-0100",
  "email": "hello@acmecoffee.example",
  "url": "https://acmecoffee.example",
  "image": "https://example.com/img/store.jpg",
  "street_address": "123 Main St",
  "locality": "New York",
  "region": "NY",
  "postal_code": "10001",
  "country": "US",
  "address_full": "123 Main St, New York, NY 10001, US",
  "latitude": 40.7128,
  "longitude": -74.006,
  "opening_hours": ["Mo-Fr 07:00-19:00", "Sa-Su 08:00-17:00"],
  "price_range": "$$",
  "rating_value": 4.6,
  "rating_best": 5,
  "rating_count": 312,
  "same_as": ["https://instagram.com/acmecoffee"],
  "fields_found": ["name", "telephone", "address_full", "rating_value"],
  "extracted_at": "2026-05-29T..."
}
```

`found:false` means no LocalBusiness markup was present (e.g. a JS-rendered locator widget).
Failed fetches return the same keys with `status:"error"` + `error`.

### Use cases

- **Local-business directories** — assemble structured listings (name, type, contact, hours, rating).
- **Lead lists** — pull public phone/email/address for businesses across a set of pages.
- **Store-locator / map datasets** — get geo coordinates + opening hours for mapping.

### Notes / safety

- Reads only **public** schema.org business markup — facts-only, only contact details the page
  itself publicly publishes; no raw page bodies stored.
- SSRF-guarded (scheme + private/metadata IP block + redirect re-check), robots-respecting,
  rate-limited, cost-capped — all via the shared `src/lib/actor_runner.js`.
- HTML-only: client-rendered pages that inject business JSON via JS return `found:false`
  (no server-side markup to read). Core logic in `src/extract.js` (pure, unit-tested).

### Run locally / test

```bash
npm install
npm test     ## unit tests on the pure extractor (node:test)
```

### Publish to Apify (account-holder's step)

```bash
npm install -g apify-cli && apify login && apify push
```

Keep it free initially; enable pricing later via the adult account-holder once it shows repeat
organic usage and clears a margin gate.

# Actor input Schema

## `startUrls` (type: `array`):

Public local-business / organization page URLs to extract structured NAP + hours + geo from.

## `maxConcurrency` (type: `integer`):

Pages extracted in parallel (capped at 20).

## `maxPages` (type: `integer`):

Cost guard: maximum pages per run (hard ceiling 200).

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.gymnasium.com/"
    }
  ],
  "maxConcurrency": 5,
  "maxPages": 100
}
```

# 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 = {
    "startUrls": [
        {
            "url": "https://www.gymnasium.com/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tom2turnt/localbusiness-extractor").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 = { "startUrls": [{ "url": "https://www.gymnasium.com/" }] }

# Run the Actor and wait for it to finish
run = client.actor("tom2turnt/localbusiness-extractor").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://www.gymnasium.com/"
    }
  ]
}' |
apify call tom2turnt/localbusiness-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=tom2turnt/localbusiness-extractor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Local Business Data Extractor (NAP, hours, geo)",
        "description": "Extract normalized local-business data — name, type, phone, email, full address, lat/long, opening hours, price range, rating — from public pages via JSON-LD (LocalBusiness subtypes, Organization), microdata, and OpenGraph. HTML-only, fast, structured ok/error output.",
        "version": "0.1",
        "x-build-id": "RqVRWsVLMQIHRFvO2"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/tom2turnt~localbusiness-extractor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-tom2turnt-localbusiness-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/tom2turnt~localbusiness-extractor/runs": {
            "post": {
                "operationId": "runs-sync-tom2turnt-localbusiness-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/tom2turnt~localbusiness-extractor/run-sync": {
            "post": {
                "operationId": "run-sync-tom2turnt-localbusiness-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Business page URLs",
                        "type": "array",
                        "description": "Public local-business / organization page URLs to extract structured NAP + hours + geo from.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxConcurrency": {
                        "title": "Max concurrency",
                        "minimum": 1,
                        "maximum": 20,
                        "type": "integer",
                        "description": "Pages extracted in parallel (capped at 20).",
                        "default": 5
                    },
                    "maxPages": {
                        "title": "Max pages",
                        "minimum": 1,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Cost guard: maximum pages per run (hard ceiling 200).",
                        "default": 100
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
