> For the complete documentation index, see [llms.txt](https://docs.predicthq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predicthq.com/getting-started/guides/geolocation-guides/searching-by-location/find-events-by-place-id.md).

# 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:

1. To get the Nottingham Place ID, make a request to the Places endpoint.
2. 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:

```python
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:

```json
{
    "id": "2641170",
    "type": "locality",
    "name": "Nottingham",
    "county": "Nottingham",
    "region": "England",
    "country": "United Kingdom",
    "country_alpha2": "GB",
    "country_alpha3": "GBR",
    "location": [
        -1.15047,
        52.9536
    ]
}
```

To search for Events happening in that location, use the Nottingham Place ID from the earlier response:

```python
import requests

response = requests.get(
    url="https://api.predicthq.com/v1/events/",
    headers={
      "Authorization": "Bearer $API_TOKEN",
      "Accept": "application/json"
    },
    params={
        "place.scope" : "2641170",  # Nottingham Place ID
        "active.gte" : "2018-03-01",
        "active.lte" : "2018-03-31",
        "category" : "sports",
        "sort" : "rank"
    }
)

print(response.json())
```

A snippet of the results looks like this:

```json
{
  "count": 19,
  "results": [
    {
      "id": "KWjlX366rrrb",
      "title": "Championship - Nottingham Forest vs Derby County",
      "category": "sports",
      ...
    }
  ]
}
```

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](http://www.geonames.org/) 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.predicthq.com/getting-started/guides/geolocation-guides/searching-by-location/find-events-by-place-id.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
