# Local Business Schema Extractor (`eichan/local-business-schema-extractor`) Actor

- **URL**: https://apify.com/eichan/local-business-schema-extractor.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Local Business Schema Extractor

Read the **JSON-LD inside exactly one publicly available business website page** and return business records. This small Actor does not crawl other pages.

### Who it is for

Local-business analysts, sales-operations teams and company-data QA staff who want **structured facts that a business has published itself**, not guesses from marketing text. Use only public official business websites. No login, personal-profile harvesting or LinkedIn access.

### Input

One HTTPS business page. A real, publicly accessible example page (not a placeholder) is provided as the input prefill:

```json
{"url": "https://firstcapitol.co.uk/debt-collection-agency-london/"}
```

The prefill URL is a live public business-page address verified through an independent public fetch on 2026-11-01. **We have not independently verified that its current HTML contains parsable JSON-LD or any particular business record.** Results depend on the page's markup at run time; a valid page can yield `not_found`.

### Output

One dataset item per recognized business declared in `<script type="application/ld+json">` (with `@graph`, arrays, and `@id` references supported). Output fields are always present:

- `name`: business name from JSON-LD, otherwise `null`
- `businessType`: explicit Schema.org `@type` (e.g. `LocalBusiness`), otherwise `null`
- `streetAddress`, `city`, `region`, `postalCode`, `country`: published `PostalAddress` fields, otherwise `null`
- `telephone`: published *business* telephone, otherwise `null`
- `openingHours`: only the `openingHours` JSON-LD property (string or array of strings); otherwise `null`
- `url`: page URL declared for that business, otherwise `null`
- `sourceUrl`: successfully fetched input page URL
- `status`: `found` or `not_found`
- `error`: `null` on a successful page read

Illustrative output (from the **simulated test fixture**, **not** a claim about the linked business):

```json
{"name":"Northstar Trade Services — London","businessType":"LocalBusiness","streetAddress":"20 Sample Avenue","city":"London","region":"Greater London","postalCode":"SW1A 1AA","country":"GB","telephone":"+44 20 5555 0111","openingHours":["Mo-Fr 09:00-17:00"],"url":"https://firstcapitol.co.uk/london","sourceUrl":"https://firstcapitol.co.uk/debt-collection-agency-london/","status":"found","error":null}
```

When no business declaration is found, exactly one row is emitted with all business-value fields set to `null`, `sourceUrl` set, `status:"not_found"`, and `error:null`.

### Honest limits

- Extracts **only** JSON-LD typed as `Organization`, `LocalBusiness`, or a supported subtype. Known Schema.org types are explicitly allowlisted; uncommon unlisted subtypes may be missed. Does not guess types from free text.
- Does **not** parse visible marketing text, tables, Microdata, RDFa, linked JSON-LD files, JavaScript-injected markup, or structured data on other pages.
- Does not transform `openingHoursSpecification` into `openingHours`; that field is `null` unless `openingHours` is explicitly present.
- Missing values stay `null`. A recognized typed business can still be found when `name` is missing; `name` remains `null`. Multiple declared business entities may yield multiple rows. Identical `@id` values are deduplicated.
- No claim that published address, phone or opening hours are current or true. These values are **self-declared** markup, not verified facts.
- One public HTTPS hostname on port 443; checks robots.txt, refuses off-host redirects, validates resolved IP addresses, uses TLS, a 12-second connection timeout, two-page requests (robots and page), and a 2 MB HTML size ceiling. No login, proxying, or cross-domain crawling.
- Some sites block automated requests or have no suitable markup. A blocked site yields a short readable `ERROR:` line (exit status 1), not a Python traceback.

### Local and Apify use

Python 3.12+, **standard library only**, no Apify SDK, no installation packages.

```bash
ACTOR_INPUT_JSON='{"url":"https://firstcapitol.co.uk/debt-collection-agency-london/"}' python src/main.py
```

Alternative local storage input: `storage/key_value_stores/default/INPUT.json`; results are written as `storage/datasets/default/000000001.json`, etc. On Apify, if `APIFY_DEFAULT_KEY_VALUE_STORE_ID` and `APIFY_TOKEN` are available, the Actor reads `INPUT` via `GET /v2/key-value-stores/{id}/records/INPUT`. If `APIFY_DEFAULT_DATASET_ID` is set, it publishes rows using `POST /v2/datasets/{id}/items` with bearer-token authorization. `ACTOR_INPUT_JSON` explicitly overrides platform input, useful for local tests. Platform API operations were tested only through a local HTTP mock, not a live Apify run.

#### Reproducible verification

```bash
python tests/run_direct_smoke.py
python -m unittest discover -s tests -v
```

The direct smoke invokes **`python src/main.py` in script mode** as a subprocess with a valid URL and a simulated offline HTTP response. The fixture is activated only with `ACTOR_TEST_HTTP=1` and test-only `PYTHONPATH`; it is never loaded in production. Read `tests/SMOKE_OUTPUT.txt`, `tests/SMOKE_DATASET.json`, and `tests/TEST_RUN_OUTPUT.txt`. No external site or Apify account was modified.

### Store metadata and suggested pricing

Category candidates: `LEAD_GENERATION`, `DATA_EXTRACTION` (maximum 2). Suggested `PRICE_PER_DATASET_ITEM`: **$4 per 1,000 dataset items** ($0.004 each). Proposal only; not configured on Apify, and not published. For customer fairness, consider whether `not_found` rows should count as billable results before enabling any future billing.

# Actor input Schema

## `url` (type: `string`):

One public HTTPS URL for a page on a business website. No login or scraping of other pages.

## Actor input object example

```json
{
  "url": "https://firstcapitol.co.uk/debt-collection-agency-london/"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# 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 = {
    "url": "https://www.ikea.com/us/en/stores/new-haven/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/local-business-schema-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 = { "url": "https://www.ikea.com/us/en/stores/new-haven/" }

# Run the Actor and wait for it to finish
run = client.actor("eichan/local-business-schema-extractor").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 '{
  "url": "https://www.ikea.com/us/en/stores/new-haven/"
}' |
apify call eichan/local-business-schema-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/local-business-schema-extractor"
        }
    }
}
```

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/ybYsPnDggFZICALbz/builds/WaAl8VOe1wWczrw7F/openapi.json
