Links

Create a Saved Location

Create a new Saved Location to begin seeing insights.

Request

HTTP Request

POST https://api.predicthq.com/v1/saved-locations

Request Headers

Header
Value
Content-Type
application/json

Request Body

Field
Description
name string required
Name of the Saved Location. E.g. My Location
description string
Description of the location.
location_code string
An optional identifier for your location. The intention here is to use your own identifier for the location if you have one. E.g., you might have stores/hotels/etc in your system with their own ID - use that ID here to make it easier to lookup the location later.
labels array
A list of labels to help you categorize your locations. You can use these labels to search upon. E.g.
{
"labels": ["label1", "label2"]
}
geojson object
You can define the geolocation of the Saved Location either by GeoJSON or Place IDs.
When using GeoJSON please note the following:
  • Currently we support Point type locations only.
  • Remember that GeoJSON coordinates are ordered longitude then latitude.
  • We require a radius to be defined using a special set of properties on the GeoJSON record. As in the example below, these are radius and radius_unit.
  • The radius property should be a numeric value.
  • The radius_unit property can be one of m (meters), km (kilometers), ft (feet), mi (miles).
As always, we strongly recommend using our Suggested Radius API to work out a suitable radius value for your location.
E.g.
{
"geojson": {
"type": "Feature",
"properties": {
"radius": 1,
"radius_unit": "mi"
},
"geometry": {
"type": "Point",
"coordinates": [
-115.1728484,
36.1147065
]
}
}
}
place_ids array
You can define the geolocation of the Saved Location either by GeoJSON or Place IDs.
The Place IDs option is typically used when the location covers an entire city, county, state or country.
Use our Places API to search for the correct Place ID.
E.g.
{
"place_ids": [2750405]
}

Response

Example response
Below is an example response:
{
"location_id": "K9XvW4KE32ZjcdqQ3WiPvg"
}

Examples

Create Using Point and Radius

curl
python
curl --location 'https://api.predicthq.com/v1/saved-locations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "Example of creating a saved location",
"geojson": {
"type": "Feature",
"properties": {
"radius": 1,
"radius_unit": "mi"
},
"geometry": {
"type": "Point",
"coordinates": [
-115.1728484,
36.1147065
]
}
}
}'
import requests
import json
url = "https://api.predicthq.com/v1/saved-locations"
payload = json.dumps({
"name": "Example of creating a saved location",
"geojson": {
"type": "Feature",
"properties": {
"radius": 1,
"radius_unit": "mi"
},
"geometry": {
"type": "Point",
"coordinates": [
-115.1728484,
36.1147065
]
}
}
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer TOKEN'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Create Using Place ID

curl
python
curl --location 'https://api.predicthq.com/v1/saved-locations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
"name": "Test with place_id",
"place_ids": [ 2750405 ]
}'
import requests
import json
url = "https://api.predicthq.com/v1/saved-locations"
payload = json.dumps({
"name": "Example with place_id",
"place_ids": [
2750405
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer TOKEN'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)

Guides

Below are some guides relevant to this API: