Introducing Directories for Places API: Discover Enriched Location Insights by Address

Foursquare’s Places API continues to expand in functionality – the Address Details API is now backed with a feature to provide better data about points of interest (POI) at an address. In conjunction with the Autocomplete API, additional information about addresses can be displayed or used to enrich the user experience. 

If you search for a commercial address in Autocomplete and follow the link to access Address Details, the response will now include a Directory field. This field shows all POIs associated with the commercial address and can be used to improve your end user experiences with rich content and even more location context.

To access this feature, begin by making an address search query using the Autocomplete API. Let’s use ‘5220 Fashion Outlets Way’ as an example: 

curl --request GET  --url 
'https://api.foursquare.com/v3/autocomplete?query=5220%20Fashion%20Outlets%20Way&session_token=92080MAVXRGADMTMKJSADCDQGMT3NDKL’ \
    --header 'Authorization: INSERT-API-TOKEN' \
    --header 'accept: application/json'
Autocomplete search results highlighting the address_id for the mall

From there, take the address_id from the response (see screenshot above) and use it to make an Address Details API request. (Hint: make sure to include a unique session_token in both API calls to ensure accurate billing! Learn more about this parameter here.) The response body also contains a field named ‘link’ that pre-populates the address_id and session_token for easy use.

For example:

curl --request GET --url 'https://api.foursquare.com/v3/address/US-555342570000072f2955-5220&session_token=92080MAVXRGADMTMKJSADCDQGMT3NDKL' \
     --header 'Authorization: INSERT-API-TOKEN' \
     --header 'accept: application/json'

The results are quick and easy to understand – if there are POIs associated with that address, a directory will be returned with location data for each POI. If there are no POIs at this address, the directory field will not appear in the response.

In the mall example, we can see the response returns rich location details about all the stores within the mall, which can be valuable information when planning business strategies and setting goals.

JSON response showing Address Directory object

The Address Directory object is similar to the related_places object that can be returned by the Places API. Related_places contains a parent and children subfield. For example, parent = Los Angeles International Airport and children = Terminal 1, Terminal 2, Terminal 3. You can learn more about the Places API Response fields here

These APIs can then be used to help create and power a more seamless location search experience. Having the additional context of what POIs are available at an address allows developers to display more useful information, while keeping users informed and engaged.
Test this feature out for yourself in our API Explorer. If you sign up for a developer account, you can receive $200 in free credits to use across all of our APIs and experience the power of location data firsthand.