# Quickstart: search Google Maps, then enrich the results

> A complete LocalPipe API example: start a Google Maps search, poll for the results, then enrich each business with its owner's name and email.
>
> Part of the LocalPipe API reference: https://www.localpipe.io/docs/quickstart (full reference in one file: https://www.localpipe.io/localpipe-api-docs.md, categories CSV: https://www.localpipe.io/localpipe-business-categories.csv)

# Full Example (Search + Enrich)

```javascript
// Step 1: Start a maps search
const searchRes = await fetch("https://uunrlffonnvmbsstkpze.supabase.co/functions/v1/maps-search", {
  method: "POST",
  headers: { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" },
  body: JSON.stringify({ query: "dentists", location: "Chicago, IL", limit: 200 })
});
const { task_id } = await searchRes.json();

// Step 2: Poll for results
let results;
while (true) {
  const poll = await fetch(
    `https://uunrlffonnvmbsstkpze.supabase.co/functions/v1/get-scrape-results?task_id=${task_id}`,
    { headers: { "apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV1bnJsZmZvbm52bWJzc3RrcHplIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA0OTIwMzMsImV4cCI6MjA4NjA2ODAzM30.8Ic_U17YrZtsDVnYnIP0XJzrhZJOLDSlJ0AZfTS31FQ" } }
  );
  results = await poll.json();
  if (results.status === "success") break;
  await new Promise(r => setTimeout(r, 15000)); // poll every 15s
}

// Step 3: Enrich each business
for (const biz of results.data) {
  if (!biz.website) continue;
  await fetch("https://uunrlffonnvmbsstkpze.supabase.co/functions/v1/enrich", {
    method: "POST",
    headers: { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" },
    body: JSON.stringify({
      business_name: biz.name,
      business_website: biz.website,
      business_location: biz.full_address,
      want_email: true,
      want_general_email: false,
      callback_url: "https://your-webhook-url.com/enrichment"
    })
  });
}
```

## Testing LocalPipe

A good sample size is **200 records** to put through enrichment to see how LocalPipe performs. Testing with **100 or more enrichment calls** is ideal for meaningful coverage results.

You can use the scraping API (`/maps-search`) with `"limit": 150` to easily gather 150 businesses for your test, then submit those records to the enrichment API.

All LocalPipe endpoints in this reference are documented and live, so no live test is needed to verify connectivity during the initial build.
