# Google Places API Leads: Importers & Wholesalers on Google Maps — API reference

The detail an integrator needs and a buyer does not, linked from the README's Integrations section.

## Tested combinations

| Call | What runs | Input |
|---|---|---|
| Daily test / first agent call | the free demo on the invented sample businesses, nothing charged | `{}` |
| Demo, as the form opens | the same free demo | `storage-example/INPUT.json` |
| A search without a Google key | the keyless OpenStreetMap live search (`liveSource: auto`) | `{"sourceMode": "live", "queries": ["rice trader Deira"]}` |
| Check a Google key | one Google request; a refusal names the fix | `{"preset": "check-google-key", "apiKey": "…"}` or `storage-example/INPUT.badkey.json` (a fake key: the refusal path) |
| Products × cities | every pair a search, plus the country's trade word | `{"sourceMode": "live", "products": ["spice"], "cities": ["Hamburg"], "regionCode": "DE"}` |
| Live search, capped | the Google Places API on your key, 1 request, AI off | `storage-example/INPUT.live.json` + `"apiKey"` |
| Refresh known places | one Place Details request per id | `{"sourceMode": "live", "placeIds": ["ChIJ…"], "apiKey": "…"}` |
| AI on | the same records with the AI verdict | `storage-example/INPUT.ai.json` |
| AI with your own key | the AI through your provider key | `{"enableAi": true, "llmProvider": "byok", "llmModel": "google:gemini-3.5-flash-lite", "llmApiKey": "…"}` + your input |
| Your own list | your rows (e.g. a Google Maps export), no Google request | `{"sourceMode": "list", "itemsList": [ … ]}` |
| A dataset you have | a dataset's items, no Google request | `{"sourceMode": "dataset", "datasetId": "<id>"}` |

## Run outcomes — every case

| Outcome | Run status | `OUTPUT.outcome` / fields | Charged? | What to do |
|---|---|---|---|---|
| Free demo (`{}` or the untouched sample) | SUCCEEDED | `ok`, `demo: true` | no | type your searches |
| Success | SUCCEEDED | `ok`, `rows`, `queries[]`, `liveSource` | per qualified lead | — |
| Nothing new — already delivered | SUCCEEDED | `empty`, `skippedAsDelivered` (status "0 new leads — N already delivered in an earlier run …") | no | `dedupeAcrossRuns: false` returns them |
| City not found (OpenStreetMap) | SUCCEEDED | `refused[]`: `{query, reason: "place not found on the map", code: "failed"}` | no | name the city as on the map |
| OpenStreetMap busy (every search) | SUCCEEDED (FAILED with `failOnSourceError: true`) | `source_busy`, `ok: false`, `queries[].refusedReasons: {"osm_rate_limited": 1}`, status "OpenStreetMap busy: Overpass busy (HTTP 504) — retry in a few minutes, or set `apiKey` for Google" | no | retry in a few minutes |
| OpenStreetMap busy (some searches) | SUCCEEDED | `ok`, `sourceBusy: ["<search>", …]`, those searches' `refusedReasons: {"osm_rate_limited": 1}` | the delivered leads only | re-run the busy searches |
| `requireEmail` dropped leads | SUCCEEDED | `ok`, `skippedNoEmail`, `stats.skipped_no_email` | no (dropped leads) | — |
| `lookalikeOf` seed not readable | SUCCEEDED | `lookalike: {seed, trade: "wholesaler", products: [], queries, error}` — the trade word alone is searched | per qualified lead | check the website address |
| `liveSource: google` without a key | FAILED | — (status names `apiKey`) | no | add the key or `liveSource: auto` |
| Nothing matched | SUCCEEDED | `empty`, `queries[].refusedReasons` | not by us (Google bills its requests) | broaden the searches |
| Demo text still in place | SUCCEEDED | `inputNeeded` | no | type your own searches |
| Invalid input | FAILED | — | no | fix the field the status names |
| Google refused key / API / billing / quota | FAILED | `source_failed`, `ok: false`, `sourceError` (never the key), e.g. "Google Places API refused the search: the Google Maps API key is not valid …" — the exact text per Google error comes from `places_api.explain_api_error` (key invalid, Places API (New) not enabled, billing off, key restricted, quota) | no | follow the reason |
| Request cap reached | SUCCEEDED | `ok`, `refused[].reason: google_request_cap` | per qualified lead | raise `maxGoogleRequests` |
| AI unavailable | SUCCEEDED | `ok`, `aiError` | basic price | `llmProvider: byok` |
| Crashed (rare) | FAILED | `error`, `ok: false` | only delivered rows | re-run; open an issue |

Alert on `refused[].code == "failed"`; `skipped` entries (cap, zero results) are expected.

## Which call runs what

| Input shape | `OUTPUT.mode` | Can it charge? |
|---|---|---|
| `{}` or the untouched form | `demo` | no |
| `sourceMode: "live"` + `queries`, no key | `live` (OpenStreetMap, `liveSource: osm` in OUTPUT) | yes, no Google request |
| a Console input saved as a task / schedule | as saved — `sourceMode` as sent, no auto-switch | as its mode |
| the sample + your key or searches typed on the Console form | `live` | yes |
| `sourceMode: "live"` + `queries` / `placeIds` + `apiKey` (over the API the mode sent runs) | `live` | yes |
| `sourceMode: "list"` + your own `itemsList` rows | `list` | yes, no Google request |
| `sourceMode: "dataset"` + `datasetId` | `dataset` | yes, no Google request |

## List-mode rows — what a pasted record needs

Paste rows into `itemsList` — [template](list-template.json):

| Field | Needed? | What it enables |
|---|---|---|
| `name` (or `title`, `displayName`) | required | the row's title |
| `placeId` | optional | dedupe key and refresh |
| `website` (or `websiteUri`, `url`, `link`) | optional | website score, e-mail lookup |
| `phone` / `internationalPhoneNumber` / `nationalPhoneNumber` / `phoneUnformatted` + `country` / `countryCode` | optional | E.164 phone, phone score |
| `types`, `primaryType`, `category` / `categoryName` / `primaryTypeDisplayName`, `categories` | optional | type match, B2B filter |
| `rating` / `totalScore`, `reviewCount` / `reviewsCount` / `userRatingCount` | optional | rating filters and score |
| `businessStatus` / `permanentlyClosed` / `temporarilyClosed` | optional | closed filter |
| `address`, `city`, `postalCode`, `placeUrl`, `foundBy`, `bestEmail`, `emails`, `description` | optional | the matching fields; `description` is read by the AI |

## API-only inputs

| Field | Default | Effect on cost and time |
|---|---|---|
| `languageCode` | `en` | language of names and addresses from Google — no cost effect |
| `includedType` / `strictTypeFiltering` | — / false | one Places type passed to Google; strict = only that type (fewer places, same request price) |
| `minRating` / `minReviews` | 0 / 0 | free filters: fewer qualified leads, never a charge for the dropped ones |
| `includeClosed` | false | true keeps closed places (flagged `closed`) — more rows can qualify and be charged |
| `allowList` | — | names / websites / place ids no free rule may drop — they can be charged if they pass `minScore` |
| `historyDatasetName` | "" | appends every delivered lead to a named dataset on your account — storage on your plan, no charge here |
| `clientName` | "" | brands the REPORT and DIGEST (agencies: one task per client) — no cost effect |
| `aiCandidateMultiplier` | 2 | AI shortlist = this × `maxQualified`: × 2 means up to twice the AI calls, time and tokens |
| `autoSwitchToLive` | true | Console only: a typed search or key next to the sample starts the live search; `false` keeps the demo |
| `discoveryTimeoutSecs` / `maxDiscoveryChargeUsd` / `discoveryActorId` / `discoveryInput` | — | template compatibility; no source Actor runs, so no effect |
| `dedupeStoreName` | `local-business-leads-ai-seen` | the default is ONE memory for every live search on the account (adding a city or a country keeps it); one named memory per client — a new name re-delivers (and re-charges) leads delivered under another |
| `placeIds` | — | Google place ids / Maps links re-read with one Place Details request each (needs your key); an unreadable id comes back in `refused[]` with `code` |
| `webhookUrl` | — | the JSON webhook (also reached through **Send alerts to**) |
| `failOnSourceError` | false | true ends a refused / failed source run FAILED so a schedule's alert fires — no cost effect |
| `webhookBatchSize` | 1 | 1 = one POST per row; N = batched POSTs — no cost effect |
| `webhookHeaders` / `webhookSecret` | — | headers / HMAC signing of the webhook POST — no cost effect |
| `slackWebhookUrl` / `teamsWebhookUrl` / `googleChatWebhookUrl` / `discordWebhookUrl` / `telegramUrl` | — | per-service aliases of **Send alerts to**; an explicit one wins for its service — no cost effect |

## The free tier and the AI reserve

Your first 25 qualified leads on this Actor are free — one free tier per Apify account, however many searches. While
the AI is unavailable on a run (plan, key, rate limit), rule-scored rows use the free leads down to a reserve of 5
kept for your first AI-assessed leads (`OUTPUT.chargeSplit.freeKeptForAi`); the status only says "N free leads left".

## Webhook body

`webhookBatchSize: 1` — one POST per lead: `{"event": "lead.qualified", "runId": "…", "redelivery": false,
"lead": {…one dataset item…}, "item": {…the same…}}`. `webhookBatchSize: N` — one POST per batch (the last may be
shorter): `{"event": "leads.qualified", "runId": "…", "redelivery": false, "leads": [ … ], "items": [ … ]}`. A 429 /
5xx / network error is retried once after 2 s (15 s timeout); a POST that still fails is re-sent first on the next run
with `"redelivery": true` — upsert on `dedupeKey`. With `webhookSecret`: header `X-Signature: sha256=<HMAC-SHA256 of
the raw body>`.

## One dataset item

From the local AI run of `storage-example/INPUT.ai.json` with the own-key default model (2026-11-24, an invented sample business — `chargedEvent: demo`):

```json
{"rowId": "demo-place-hh-0001-2026-11-24", "itemId": "demo-place-hh-0001", "name": "Hanse Spice Import GmbH (sample)",
 "url": "https://hanse-spice-import.example", "address": "Demo-Kai 12, 20457 Hamburg, Germany", "city": "Hamburg",
 "postalCode": "20457", "country": "DE", "phone": "+494099900101", "phoneRaw": "040 99900101", "website": "https://hanse-spice-import.example",
 "websiteDomain": "hanse-spice-import.example", "rating": 3.9, "reviewCount": 23, "placeId": "demo-place-hh-0001",
 "types": ["wholesaler", "store", "point_of_interest", "establishment"], "primaryType": "wholesaler", "category": "Wholesaler",
 "businessStatus": "OPERATIONAL", "placeUrl": "https://www.google.com/maps/search/?api=1&query=Hanse+Spice+Import+GmbH+Hamburg",
 "foundBy": ["spice wholesaler Hamburg"], "bestEmail": "einkauf@hanse-spice-import.example", "emails": ["einkauf@hanse-spice-import.example", "info@hanse-spice-import.example"],
 "emailStatus": "sample", "emailSource": "https://hanse-spice-import.example/impressum", "attribution": "Google Maps",
 "typeMatch": "b2b", "contactRoute": "mailto:einkauf@hanse-spice-import.example", "flags": ["b2b_type", "b2b_name", "product_match", "has_website", "has_phone"],
 "targetFlagsMatched": [], "ruleScore": 95, "score": 95, "fitLabel": "hot", "fitScore": 95, "scoreReasons": ["explicitly states it is an importer of spices from India on its website", "listed as a wholesaler and categorized as b2b with matching product search", "supplies food manufacturers and retailers in Northern Germany from its Hamburg warehouse"],
 "businessKind": "importer", "productsHandled": ["whole and ground spices", "black pepper", "cumin", "turmeric", "cardamom"],
 "productFit": "strong", "summary": "Hanse Spice Import GmbH is a Hamburg-based importer and wholesaler of whole and ground spices from India and other origins, supplying food manufacturers and retailers.",
 "generatedText": "I saw that you import whole and ground spices like black pepper and turmeric from India for food manufacturers and retailers in Northern Germany.\nWould you be interested in sourcing premium Indian whole spices and basmati rice in 20 ft containers directly from our export operations?",
 "recommendedNextStep": "Send an introductory email to einkauf@hanse-spice-import.example offering Indian whole spices and basmati rice for their warehouse supply.",
 "aiModel": "google:gemini-3.5-flash-lite", "assessedBy": "ai", "chargedEvent": "demo", "billedAs": "qualified-lead-ai",
 "dedupeKey": "demo-place-hh-0001", "source": {"mode": "list", "query": "spice wholesaler Hamburg"}, "fetchedAt": "2026-11-24T04:46:18+00:00"}
```

## `OUTPUT` record keys

- `ok` — bool: `false` when Google refused the key / API / billing, or the source failed with nothing loaded
- `outcome` — str: `ok` · `empty` · `source_busy` (OpenStreetMap throttled every search — retry) · `source_refused` ·
  `source_failed` · `error`
- `sourceBusy` — array | null: searches OpenStreetMap was too busy for (`refusedReasons.osm_rate_limited`)
- `skippedNoEmail` — int | null: leads `requireEmail` dropped (never charged)
- `lookalike` — object | null: `{seed, trade, products, queries, error}` — the profile `lookalikeOf` read and the
  searches built from it
- `mode` — str: `demo` · `live` · `list` · `dataset`
- `rows` / `qualified` — int: rows delivered this run
- `refused` — array: `{query | placeId, reason, code}`; `reason` ∈ `google_request_cap` · `zero_results` · `place_not_found`;
  `code` ∈ `skipped` (expected) · `failed` (a place id that should read) · `not_supported` (not an id or Maps link) — alert on `code == "failed"`
- `queries` — array: `{query, requests, found, kept, qualified, refusedReasons}` per search
- `costUsd` — number: this Actor's charge of the run (our events) — never the Google bill
- `googleRequests` — object: `{textSearchEnterprise, placeDetailsEnterprise}`; `googleListCostUsd` — number (requests × first-tier list price); `googleCostNote` — str
- `attribution` — `"Google Maps"`, or `"© OpenStreetMap contributors (ODbL)"` for a keyless run; `liveSource` — `google` · `osm`; `osmRequests` — `{nominatim, overpass}` | null
- `skippedAsDelivered` — int | null: matches an earlier run delivered (not charged again); `aiRejected` — int | null: units the AI (or a labelled sample verdict) scored below `minScore`
- `emailLookup` — object | null: `{sites, email, no_email, blocked, notReached}`
- `stats` — object: the funnel, `discovered`, `skipped_<reason>` (`retail_only`, `closed`, `no_website`, `below_min_rating`, `below_min_reviews`, …)
- `skips` — object | null: `{"<reason>": ["<name>", …]}`
- `chargedEvents` — object; `chargeSplit` — object: `demo`, `free`, `basic`, `ai`, `freeKeptForAi`
- `sourceError` — str | null (the plain reason, never the key); `sourceStatus` — object | null
- `aiCoverage` — object | null: `aiAssessed`, `ruleScored`, `fallbackReasons`, `sampleVerdicts`; `aiError` — str | null
- `aiTokens` — object | null: `inputPerUnit`, `outputPerUnit`, `model`
- `webhook` — object | null: `sent`, `failed`, `failedKeys`, `redelivered`, `pendingNextRun`, `signed`
- `trend`, `history`, `dedupeStore`, `scheduleInput`, `scheduleTaskUrl`, `reportUrl`, `timing`, `nextSteps` — as in the template

## Every field of a row

| Field | Description |
|---|---|
| `name`, `address`, `city`, `postalCode`, `country` | Google's name and address; `country` ISO-2 |
| `phone`, `phoneRaw` | E.164 (never guessed) and the number as Google lists it |
| `website`, `websiteDomain`, `url` | the website; `url` = website, else the Google Maps page |
| `liveSource` | where the row's data comes from: `google` (Places API on your key — rating, review count, Google types), `osm` (keyless OpenStreetMap — name, address, trade tags, phone / website / e-mail when mapped; no rating or review count), `list` / `dataset` (your rows) |
| `bestEmail`, `emails`, `emailStatus`, `emailSource` | best e-mail from the company's own site (MX found = `ok`; `sample` on demo rows), all found, the page it was on |
| `rating`, `reviewCount` | Google rating and review count (no review text) |
| `placeId`, `placeUrl`, `types`, `primaryType`, `category`, `businessStatus` | Google's ids, types and status |
| `typeMatch`, `foundBy`, `flags`, `targetFlagsMatched` | b2b / neutral / retail, the searches that found it, rule flags |
| `ruleScore`, `score`, `fitScore`, `fitLabel`, `scoreReasons`, `assessedBy` | sort on `score`, trend on `ruleScore`; hot ≥ 70, warm ≥ 45 |
| `businessKind`, `productsHandled`, `productFit`, `summary` | the AI's verdict (null without AI) |
| `generatedText`, `recommendedNextStep`, `contactRoute` | first message, next step, best way in (e-mail → phone → site) |
| `attribution`, `chargedEvent`, `billedAs`, `aiModel`, `source` | provenance and billing |
| `fetchedAt` | when this run read the place from Google (UTC) |
| `rowId`, `itemId`, `dedupeKey` | `itemId` = `dedupeKey` = `placeId`, stable per lead; `rowId` = `itemId` + the date this run read the place from Google (`fetchedAt`, UTC) |

## Run time per mode

| Mode | Time | `timeoutSecs` |
|---|---|---|
| Free demo | 0.2 s (measured 2026-11-24) | 120 |
| Your own rows, rules only | under 1 s per 100 | 300 |
| Live search, rules only | ≈ 1 min for 2 searches with e-mails (estimate) | 600 |
| AI via Apify's model access | ≈ 6 s per lead, 8 at a time (estimate) | 900 |
| AI with a free own key | 1–3 leads per run, then rule scores (2 min rate-limit budget) | 900 |
| AI with a paid own key | measured 2026-11-24: 8.0–14.6 s per lead ≈ 4–7 leads a minute (local gateway model) | 1800 |

## Delivery fields and CRM mapping

**Merge rule — which wins when both are sent:** `sendAlertsTo` and the per-service aliases (`slackWebhookUrl`,
`discordWebhookUrl`, `teamsWebhookUrl`, `googleChatWebhookUrl`, `telegramUrl`) are a union by service — an explicit
per-service field wins for its service, `sendAlertsTo` fills every service left empty, and no URL is posted twice.

Every URL is posted once per run: **Send alerts to** (`sendAlertsTo`) fills each service you did not set yourself, an
explicit per-service field over the API wins for that service; `webhookUrl` gets the rows as JSON, Slack / Discord /
Teams / Google Chat / Telegram and `notifyEmail` get the digest. HubSpot / Pipedrive: a Make / Zapier "create or
update" step — company = `name` + `website`, phone = `phone`, e-mail = `bestEmail`, note = `generatedText`; upsert on
`dedupeKey`.

## The same call in JavaScript

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

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });
const run = await client.actor('<your-apify-username>/local-business-leads-ai').call({
    // free first call instead: {} (the demo) or { sourceMode: 'list', itemsList: [{ name: '…', website: '…' }] }
    sourceMode: 'live',
    queries: ['spice wholesaler Hamburg', 'rice trader Deira'],
    apiKey: '<YOUR_GOOGLE_PLACES_KEY>',
    maxQualified: 50,
    maxGoogleRequests: 10,
    dedupeAcrossRuns: true, // a re-run skips leads already delivered — false to get them again
    failOnSourceError: true,
}, { timeout: 1800 /* , build: '0.1.1' */ });
if (run.status !== 'SUCCEEDED') throw new Error(`${run.status}: ${run.statusMessage}`);
const rec = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT');
const out = rec ? rec.value : {};
if (out.ok === false) throw new Error(`${out.outcome}: ${out.sourceError}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((i) => [i.name, i.score, i.url]));
```
