-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Determine this is the right repository
- I determined this is the correct repository in which to report this feature request.
Summary of the feature request
When using the new Places SDK, it is not possible to paginate through API results. The SDK does not provide a way to handle next_page_token or retrieve additional result pages, which limits the number of places that can be fetched from a single query.
Desired code experience
import asyncio
from google.maps.places_v1 import PlacesAsyncClient
from google.api_core.client_options import ClientOptions
from dotenv import load_dotenv
import os
load_dotenv()
PLACES_API_KEY = os.getenv("PLACES_API_KEY")
if not PLACES_API_KEY:
print("Error: PLACES_API_KEY not found. Please check your .env file.")
exit()
async def search_places():
client_options = ClientOptions(api_key=PLACES_API_KEY)
client = PlacesAsyncClient(client_options=client_options)
text_response = await client.search_text(
request={
"text_query": "Restaurantes,Bogotá,Colombia",
"language_code": "es-419",
"max_result_count": 20,
},
metadata=[("x-goog-fieldmask", "places.id,next_page_token,nextPageToken")]
)
print(text_response)
asyncio.run(search_places())
Expected results
I need the SDK to return not only the places, but also the next_page_token. Looking at the SearchTextResponse and SearchNearbyResponse objects, this field does not seem to be included. Without it, I am unable to access more than 20 places from a single query."
API client name and version
google-maps-placesv0.2.2
Use case
This feature is useful in cases where I need to retrieve all the places returned by the API through pagination.
Additional context
I need the SDK to return not only the places, but also the next_page_token. Looking at the SearchTextResponse and SearchNearbyResponse objects, this field does not seem to be included. Without it, I am unable to access more than 20 places from a single query.