Query Event Data
Query events
This code queries data from the events where an event property has a certain value using the PropertyFilter (my Swagger). The following script requires an EventTypeUUID to be filled in. The event type UUID can be retrieved either programmatically or via the web interface. Also fill in the Property you want to filter on and its Value. The Value of each filter is a list.
GET /api/events with the filter as query parameters still works, but it is deprecated. Use POST /api/events/query instead.
def query_events(query):
resp = session.post(f"{BASE_URL}/events/query", json=query, timeout=60)
resp.raise_for_status()
return resp.json()
query = {
"Filter": {
"EventTypeUUIDs": ["my-event-type-uuid"],
"PropertyFilter": [{
"Property": "property-name",
"Datatype": "string",
"Operator": "=",
"Value": ["value-of-event-property"] # always a list, with one item unless Operator is IN or NOT IN
}]
},
"Limit": 100
}
events = query_events(query)
print(json.dumps(events, indent=2))