Skip to content

AWS Places API v2 SearchText missing NextToken in pagination

2

I am getting exactly MaxResults number of results (100 when you set 100, 20 when you set 20) for the same query, and there's no NextToken returned, which indicates the API is incorrectly truncating results without providing pagination tokens.

The NextToken is also missing from the sample response in the AWS demo here

Amazon Location Services, Places API, Search Text endpoint

Expected behavior: When you get exactly MaxResults items back, there should be a NextToken if more results exist

Actual behavior: API returns exactly the number you request (20 when MaxResults=20, 100 when MaxResults=100) but fails to provide NextToken Impact: You can't access results beyond the first page, regardless of how many total results exist

curl -X POST "https://places.geo.us-east-1.amazonaws.com/v2/search-text?key={api-key}" \
  -H "Content-Type: application/json" \
  -d '{
    "QueryText": "restaurants",
    "Filter": {
      "Circle": {
        "Center": [-80.8431, 35.2271],
        "Radius": 10000
      }
    },
    "MaxResults": 1
  }'
{"ResultItems":[{"PlaceId":"AQAAAFUAVuUJFMrPzsO99c511VYZbJI59Pzmyn2v6SiOvF2IHdxQya8Gm5iPoIjTbZ4xqpQSqOhRb9TMEBGZxw_Le-0hbG8ageDlJgdxr-qnnJ8pFQoObFiVvl7kKgNccIUX5TESNs2pGgAlfxKbpkheBNw7FMLjoPBu","PlaceType":"PointOfInterest","Title":"Red Salsa Marketing","Address":{"Label":"Red Salsa Marketing, S Tryon St, Charlotte, NC 28202, United States","Country":{"Code2":"US","Code3":"USA","Name":"United States"},"Region":{"Code":"NC","Name":"North Carolina"},"SubRegion":{"Name":"Mecklenburg"},"Locality":"Charlotte","District":"Bank of America Stadium","PostalCode":"28202","Street":"S Tryon St","StreetComponents":[{"BaseName":"Tryon","Type":"St","TypePlacement":"AfterBaseName","TypeSeparator":" ","Prefix":"S","Language":"en"}]},"Position":[-80.84316,35.22713],"Distance":6,"Categories":[{"Id":"commercial_services","Name":"Commercial Services","LocalizedName":"Commercial Services","Primary":true},{"Id":"restaurant","Name":"Restaurant","LocalizedName":"Restaurant","Primary":false},{"Id":"specialty_trade_contractors","Name":"Specialty Trade Contractors","LocalizedName":"Specialty Trade Contractors","Primary":false},{"Id":"wellness_center_and_services","Name":"Wellness Center and Services","LocalizedName":"Wellness Center \u0026 Services","Primary":false},{"Id":"fitness-health_club","Name":"Fitness-Health Club","LocalizedName":"Fitness/Health Club","Primary":false}],"FoodTypes":[{"LocalizedName":"American","Id":"american","Primary":true}]}]}% 
{
  "reproduction_steps": [
    "1. Call SearchText API with MaxResults=20 for query that has >20 results",
    "2. Observe: Get exactly 20 results with no NextToken", 
    "3. Call same query with MaxResults=100",
    "4. Observe: Get exactly 100 results (proving more exist)",
    "5. Expected: Step 2 should include NextToken for pagination"
  ],
  "expected_behavior": "NextToken should be returned when more results are available",
  "actual_behavior": "NextToken is never returned regardless of result set size",
  "impact": "Cannot access results beyond first page"
}

asked a year ago132 views

2 Answers
5

Above was identified as known issue and what can do should be monitor SDK and API changelogs or consider to reduce MaxResults as workaround

EXPERT

answered a year ago

0

Hey,

Hope you're keeping well.

The Places API v2 SearchText endpoint only returns a NextToken if the underlying data provider has more results to paginate. If you get exactly MaxResults items without a token, it often means the provider’s result set ended at that count, even if you expect more matches. The sample console response omitting NextToken is consistent with this behavior. To confirm, try lowering MaxResults (e.g., 10) and see if a token appears, or adjust your filters to broaden the search.

Thanks and regards,
Taz

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.