# Search Events for a Saved Location

## Search Events for a Saved Location

> Returns events that impact the specified Saved Location. Please refer to the \[Events API]\(<https://docs.predicthq.com/api/events/search-events>) docs for the available query parameters in addition to those listed below.

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Saved Locations API","version":"1.0.0"},"tags":[{"name":"Saved Locations API"}],"servers":[{"url":"https://api.predicthq.com"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"$API_KEY","description":"Enter your PredictHQ API key. The Bearer prefix is added automatically.\n\nWhen calling the API directly, send: `Authorization: Bearer <YOUR_API_KEY>` as documented at [https://docs.predicthq.com/api/overview/authenticating](https://docs.predicthq.com/api/overview/authenticating)\n"}},"schemas":{"DateRangeType":{"description":"The type of date range for insight calculations. Currently only `next_90d` is supported.","type":"string","const":"next_90d","title":"DateRangeType"},"PhqEvents":{"description":"A paginated list of events impacting a Saved Location.","type":"object","properties":{"count":{"description":"Total number of results found.","type":"integer","title":"Count"},"results":{"description":"List of results where each item is an Event.\n\n\nPlease refer to the response fields section in [Search Events](https://docs.predicthq.com/api/events/search-events#response-fields) for the structure of each record.","type":"array","items":{"additionalProperties":true,"type":"object"},"title":"Results"}},"required":["count","results"],"title":"PhqEvents"},"HTTPValidationError":{"description":"A validation error response containing field-level error details.","type":"object","properties":{"error":{"description":"A summary error message.","type":"string"},"details":{"description":"A list of field-level validation errors.","type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}},"title":"HTTPValidationError"},"ValidationError":{"description":"A single field-level validation error.","type":"object","properties":{"field":{"description":"The field path that caused the error.","type":"string"},"msg":{"description":"A human-readable error message.","type":"string","title":"Message"},"type":{"description":"The type of validation error.","type":"string","title":"Error Type"}},"title":"ValidationError"},"ErrorResponse":{"description":"An error response containing a human-readable error message.","type":"object","properties":{"error":{"description":"Error message","type":"string","title":"Error"}},"required":["error"],"title":"ErrorResponse"}},"parameters":{"OffsetParam":{"name":"offset","in":"query","description":"Offset the results.","required":false,"schema":{"type":"integer","default":0}},"LimitParam":{"name":"limit","in":"query","description":"Limit the number of results.","required":false,"schema":{"type":"integer","default":10}}}},"paths":{"/v1/saved-locations/{location_id}/insights/events":{"get":{"operationId":"list_saved_location_insight_events","summary":"Search Events for a Saved Location","description":"Returns events that impact the specified Saved Location. Please refer to the [Events API](https://docs.predicthq.com/api/events/search-events) docs for the available query parameters in addition to those listed below.","parameters":[{"name":"location_id","in":"path","description":"An existing Saved Location ID.","required":true,"schema":{"type":"string","title":"Location Id"}},{"name":"date_range_type","in":"query","description":"Date range to fetch events for.\n\n\nCurrently the only supported date ranges are:\n\n\n- `next_90d`","required":false,"schema":{"$ref":"#/components/schemas/DateRangeType","title":"Date Range Type"}},{"$ref":"#/components/parameters/OffsetParam"},{"$ref":"#/components/parameters/LimitParam"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhqEvents"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"tags":["Saved Locations API"]}}}}
```

## Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl --location 'https://api.predicthq.com/v1/saved-locations/0b6ZrOnTdB2Y7k4zC_9qBg/insights/events?date_range_type=next_90d&category=public-holidays%2Csports&sort=start' \
--header 'Authorization: Bearer TOKEN'
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = "https://api.predicthq.com/v1/saved-locations/0b6ZrOnTdB2Y7k4zC_9qBg/insights/events?date_range_type=next_90d&category=public-holidays,sports&sort=start"

payload={}
headers = {
  'Authorization': 'Bearer TOKEN'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

## OpenAPI Spec

The OpenAPI spec for Saved Locations API can be [found here](https://api.predicthq.com/docs/?urls.primaryName=Saved+Locations+API).

## Guides

Below are some guides relevant to this API:

* [Working with Location-Based Subscriptions](/getting-started/guides/geolocation-guides/searching-by-location/working-with-location-based-subscriptions.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.predicthq.com/api/saved-locations/search-events-for-a-saved-location.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
