Skip to main content

errand_search_addresses

Finds addresses and returns two result sets at once: candidates, the places found by the search, and saved_matches, addresses the user has already saved that match this search. The same place name can have multiple matches — never auto-pick the first one, let the user choose. Addresses in saved_matches already have their door number and contact phone filled in, so the user can place an order right away without repeating that information.
Address flow: once you find a candidate place, save it with errand_save_address. An address that already appears in saved_matches is already saved — skip saving and use its id directly as address_id.

Two ways to search — supply at least one

  • The user named a place (“send it to People’s Square”) → pass keyword, optionally with city to narrow it down.
  • The user said “from where I am right now” → there is no place name to search on; pass their lat / lng. You get back the names this location belongs to, from specific to broad (e.g. “星洲花园南区圣陶沙韵”, “星洲花园南区”, “星洲花园”), so the user can confirm which one is right.
  • Both supplied → the search runs on keyword, and the coordinates only rank nearby results first.
When the user names a place, do not let the coordinates override keyword — otherwise “send it to People’s Square” turns into a search for where they are standing.

Parameters

Returns

When the search returns nothing and the user has no saved addresses, the response is { "candidates": [], "saved_matches": [] } — this is not an error.

Error Codes

See Error Handling for the full list.

Call Example

By place name:
By current location: