Addresses
Autocomplete
Autocomplete allows you to submit a piece of an address string and have the API respond with the best possible options. For better user experience, the API does not respond with unit numbers but instead expects the UI to include another input field for the user to enter their line2
address.
region
: Region is an optional parameter that can be used to filter the results to a specific country. The region parameter is a two-letter country code that can be used to filter the results to a specific country. If the region parameter is not provided, the API will return results from all countries.
Request
Response
You'll then be returned the best five predictions that the API has for your input. The JSON response would look something like this:
Usage
If using autocomplete on the frontend, make sure that you use a debouncing mechanism to ensure that requests are sent at reasonable time intervals so that you don't encounter any rate limits on your account.
In addition, many addresses also have a unit, suite, floor, etc. that does not get returned in the autocomplete API. All of our address APIs, when creating a shipment
, contact
, etc., enable you to add the secondary address line in a property called address_line2
. As a result, you'll typically want to also have a secondary input in your form to collect this value.
Commonly after autocompletion the value, you'll then subsequently pass the address and address_line2 properties to the address parsing API to receive back the PackageX address model.