Try a request
curl https://api.nativeport.ai/serper/places \
-H "Authorization: Bearer $NATIVEPORT_API_KEY" \
-H "Content-Type: application/json" \
--data '{"q": "1600 Amphitheatre Parkway, Mountain View"}'{
"places": [
{
"title": "Googleplex",
"address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043",
"latitude": 37.4220541,
"longitude": -122.0853242,
"placeId": "ChIJj61dQgK6j4AR4GeTYWZsKWw",
"category": "Corporate office",
"rating": 4.4,
"ratingCount": 6321
}
]
}Look up a complete address
Send an address or place name in the q field. Including the city or region can
help distinguish similar names. The response contains matching listings with
coordinates and other available details.
Check the returned name and address before accepting a match. The Python example uses the first result to show a simple batch workflow; your app may need to review ambiguous results or present several choices.
This is a server-side place lookup. It does not provide the suggestions shown while a person is still typing in an autocomplete field. If your interface needs those suggestions, use a dedicated autocomplete service for that step.
To process a list, send one query per row and write the matched address and coordinates to your output. Keep unmatched rows for review. The result can also include business details, which may save a separate lookup when you are enriching a directory.
Add coordinates to a list of addresses
Reads one address per line from standard input and writes matching addresses and coordinates as CSV.
import csv, json, os, sys, urllib.request
def lookup(query):
req = urllib.request.Request(
"https://api.nativeport.ai/serper/places",
data=json.dumps({"q": query}).encode(),
headers={
"Authorization": f"Bearer {os.environ['NATIVEPORT_API_KEY']}",
"Content-Type": "application/json",
},
)
with urllib.request.urlopen(req) as r:
places = json.load(r).get("places") or []
return places[0] if places else None
out = csv.writer(sys.stdout)
out.writerow(["query", "matched", "lat", "lon"])
for line in sys.stdin:
q = line.strip()
if not q:
continue
hit = lookup(q)
if hit:
out.writerow([q, hit["address"], hit["latitude"], hit["longitude"]])
else:
out.writerow([q, "NO MATCH", "", ""])$ printf '1600 Amphitheatre Parkway\nnot a real place xyz\n' | python geocode.py query,matched,lat,lon 1600 Amphitheatre Parkway,"1600 Amphitheatre Pkwy, Mountain View, CA 94043",37.4220541,-122.0853242 not a real place xyz,NO MATCH,,
Use it with NativePort
Use Serper Places with your NativePort key. The same account and balance cover other search providers and follow-up requests for your location workflow.
Before you start
Can I use this for address autocomplete?
This endpoint looks up a complete query. For suggestions that update as someone types, use a dedicated autocomplete service. Use this guide for server-side lookups after you have an address or place name.
What comes back besides coordinates?
A matching listing can include its name, formatted address, place ID, category, rating, and review count. Check which fields are present before using them.
What does a lookup cost?
Serper queries use credits. Check the Serper provider page for the current rate and allow for one request per query in the batch example.
What if no place matches?
Check whether places is empty before reading a result. The example writes NO MATCH for that row, so you can review it afterwards.