The problem
A business name can match several locations. An agent needs to identify the right branch before using its reviews, and a rating alone cannot explain the customer experience. Plain web retrieval often fails to turn Yelp’s search results and paginated reviews into usable records.
How NativePort helps
NativePort gives your agent access to Yelp search and review retrieval through SerpApi. First find the business and check its location. Then retrieve reviews for that business so the agent can summarize feedback tied to the correct place.
Technical implementation
Use Python 3 with requests installed (python -m pip install requests). Set NATIVEPORT_API_KEY in your environment to your NativePort key. Run the snippets on your server, where your key stays private.
Set YELP_QUERY to a business name or category and YELP_LOCATION to a city or address. Run this Yelp search to inspect matching listings.
import json
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
response = requests.get(
BASE + "/serpapi",
headers=HEADERS,
params={"engine": "yelp", "find_desc": os.environ["YELP_QUERY"],
"find_loc": os.environ["YELP_LOCATION"]},
timeout=120,
)
response.raise_for_status()
result = response.json()
if result.get("error"):
raise RuntimeError(result["error"])
businesses = result.get("organic_results", [])
print(json.dumps(businesses, indent=2, ensure_ascii=False))Choose the intended business by name and address. Set YELP_PLACE_ID to its opaque place_id from the search response, not the readable URL slug. This second request retrieves up to ten reviews using the Yelp Reviews engine.
import json
import os
import requests
BASE = "https://api.nativeport.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}"}
response = requests.get(
BASE + "/serpapi",
headers=HEADERS,
params={"engine": "yelp_reviews", "place_id": os.environ["YELP_PLACE_ID"],
"sortby": "date_desc", "num": 10},
timeout=120,
)
response.raise_for_status()
result = response.json()
if result.get("error"):
raise RuntimeError(result["error"])
reviews = result.get("reviews", [])
print(json.dumps(reviews, indent=2, ensure_ascii=False))The complete example makes two calls, listed separately below. If you already have the correct place ID, only the review lookup is needed. Keep the business ID and review dates with the output. A single page of reviews is a sample; collecting another page requires another request.
Tool costs
| Tool used in the example | Price per call |
|---|---|
| SerpApi — Yelp business search | $0.026375 / call |
| SerpApi — Yelp reviews lookup | $0.026375 / call |
Prices in USD. Usage-based tools have no fixed per-call price. View pricing.
Let your agent build it
You don’t need to write this code yourself. Copy this page’s link and paste it into your agent. Ask it to follow the guide and implement the feature for you.