Find events by place ID
For this example, we want to find all the sports events that happened in Nottingham, England in March of 2018.
To find the events, follow these steps:
To get the Nottingham Place ID, make a request to the Places endpoint.
To get the events, make a request to the Events endpoint with that Place ID.
The first request finds the Nottingham Place ID by calling the Places endpoint:
import requests
response = requests.get(
url="https://api.predicthq.com/v1/places/",
headers={
"Authorization": "Bearer $API_TOKEN",
"Accept": "application/json"
},
params={
"q": "Nottingham,England"
}
)
print(response.json())The first result in the response is the correct location we want:
To search for Events happening in that location, use the Nottingham Place ID from the earlier response:
A snippet of the results looks like this:
We use Geonames data for our Places, so the id 2641170 is also a Geoname ID for the same location. See the official Geonames site for more information.
Using place.scope returns events that apply to the parent and children places of the specified place (e.g. holidays and other events that apply to a country or region). Alternatively you can use place.exact to return events that apply to the specified place only.
Last updated
Was this helpful?