# Best practices and common questions

> How to batch keywords and locations, size the limit, and read the per-pair breakdown when a LocalPipe search returns zero results for a city or keyword.
>
> Part of the LocalPipe API reference: https://www.localpipe.io/docs/best-practices (full reference in one file: https://www.localpipe.io/localpipe-api-docs.md, categories CSV: https://www.localpipe.io/localpipe-business-categories.csv)

## Best Practices

1. **Always batch locations.** Pass every city in a single `/maps-search` call (up to 100 locations). It is MUCH faster, consumes one rate-limit slot, and avoids the data loss that comes from looping per-city.
2. **Batch keywords too.** With an integer `limit`, the budget is split evenly across every keyword × location pair (unused share is redistributed), so batching never starves later keywords. Need N per pair? Set `limit = N × pairs`.
3. **Cap your client at ≤ 1000 requests/minute** — anything above this is rejected with 429 and lost unless you retry
4. **Always retry 429 responses** — honor `Retry-After` (60s default), then back off exponentially. A 429 means the call was *not* accepted
5. **Always use callback_url** for Clay and automation platforms — avoids timeout issues
6. **Split large locations** — searching "Texas" searches top 50 cities; for full coverage, list specific cities
7. **Use filters** to reduce noise — `has_website: true` and `min_rating: 3.5` dramatically improve lead quality
8. **Poll every 15 seconds** — most small searches complete in under 60 seconds
9. **Combine search + enrich** — use maps search to find businesses, then enrich each one for owner contact info

## Why did some of my locations or keywords return zero results?

With multi-keyword × multi-location batches, `limit` is divided evenly across pairs and any unused share is redistributed to pairs that still have more matches. So a pair returning zero results means Google had no matching businesses for that exact combination. If most pairs still look truncated, your `limit` is simply too small for the number of pairs — raise it or use `"limit": "all"`.

Verify this by reading `sub_query_breakdown` in the completed response (returned for multi keyword × location tasks with an integer `limit`; single-pair tasks and `"limit": "all"` tasks omit it):

```json
{
  "sub_query_breakdown": {
    "by_location": [
      { "location": "Sydney, Australia", "found": 505, "returned": 300, "truncated": true },
      { "location": "Perth, Australia", "found": 0, "returned": 0, "truncated": false }
    ],
    "by_keyword": [
      { "keyword": "dermatology clinic", "found": 505, "returned": 300, "truncated": true }
    ]
  }
}
```

- `found: 0, truncated: false` → no matches for that location/keyword. Do not re-run it separately.
- `found: > 0, truncated: true` → matches exist but the task hit its global `limit`. Raise `limit` (e.g. `N × pairs`) or switch to `"limit": "all"` for full coverage.
- `found: > returned, truncated: true` → normal behavior for an integer cap.

If you see `truncated: true` on every pair, your `limit` is simply lower than the available density in those areas.

## Should I split a batch into one request per city or keyword?

No. Batch both locations and keywords (up to 1,000 keywords and 100 locations per call). With an integer `limit` the budget is split evenly across pairs and unused share is redistributed, so no keyword or city is starved. If you need more total results, raise `limit` (max 1,000,000) or use `"limit": "all"`. Use `sub_query_breakdown` to tell truncation apart from a genuinely empty pair.
