> For the complete documentation index, see [llms.txt](https://docs.jua.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jua.ai/api-v2/query-engine/examples/regional-queries.md).

# Regional Queries

{% hint style="warning" %}
Regional queries without aggregation can end-up consuming a lot of credits. The `request_credit_limit` was increased for all of the example queries.

Use with care!
{% endhint %}

### Countries & Market Zones

#### Country

{% tabs %}
{% tab title="Example (Python)" %}

```python
query = {
    "models": ["ept2"],
    "geo": {
        "type": "country_key",
        "value": "CH",  # Switzerland
    },
    "variables": ["air_temperature_at_height_level_2m"],
    "init_time": "latest",
    "prediction_timedelta": [0, 24, 48],  # 0, 1 day, 2 days
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for Switzerland")
print(df.head())
```

{% endtab %}

{% tab title="Output" %}

```
✅ Retrieved 2106 rows for Switzerland
  model           init_time  ... longitude  air_temperature_at_height_level_2m
0  ept2 2025-10-23 06:00:00  ...  8.916667                          284.200012
1  ept2 2025-10-23 06:00:00  ...  7.083333                          273.100006
2  ept2 2025-10-23 06:00:00  ...  7.166667                          273.300018
3  ept2 2025-10-23 06:00:00  ...  7.250000                          273.100006
4  ept2 2025-10-23 06:00:00  ...  8.916667                          283.899994

[5 rows x 6 columns]
```

{% endtab %}
{% endtabs %}

#### Market Zone

{% tabs %}
{% tab title="Example (Python)" %}

```python
query = {
    "models": ["ept2"],
    "geo": {
        "type": "market_zone",
        "value": ["GB-NIR"],  # Northern Ireland
    },
    "variables": ["wind_speed_at_height_level_100m"],
    "init_time": "latest",
    "prediction_timedelta": [0, 24],  # 0 and 1 day ahead
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for Northern Ireland")
print(df.head())
return df
```

{% endtab %}

{% tab title="Output" %}

```
✅ Retrieved 572 rows for Northern Ireland
  model           init_time  ... longitude  wind_speed_at_height_level_100m
0  ept2 2025-10-23 06:00:00  ... -6.666667                        10.300000
1  ept2 2025-10-23 06:00:00  ... -6.583333                        10.200000
2  ept2 2025-10-23 06:00:00  ... -6.500000                         9.900001
3  ept2 2025-10-23 06:00:00  ... -6.416667                         9.900001
4  ept2 2025-10-23 06:00:00  ... -6.166667                         9.900001

[5 rows x 6 columns]
```

{% endtab %}
{% endtabs %}

### Bounding Boxes

{% tabs %}
{% tab title="Example (Python)" %}

```python
query = {
    "models": ["ept2"],
    "geo": {
        "type": "bounding_box",
        "value": [
            [45.8, 5.9],  # [lat_min, lon_min] - Southwest corner
            [47.8, 10.5],  # [lat_max, lon_max] - Northeast corner
        ],  # Switzerland region
    },
    "variables": ["air_temperature_at_height_level_2m"],
    "init_time": "latest",
    "prediction_timedelta": [0],  # IC only
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 150}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for bounding box")
print(df.head())
return df
```

{% endtab %}

{% tab title="Output" %}

```
✅ Retrieved 1344 rows for bounding box
  model           init_time  ... longitude  air_temperature_at_height_level_2m
0  ept2 2025-10-23 06:00:00  ...  5.916667                          287.000000
1  ept2 2025-10-23 06:00:00  ...  6.000000                          286.700012
2  ept2 2025-10-23 06:00:00  ...  6.083333                          286.200012
3  ept2 2025-10-23 06:00:00  ...  6.166667                          285.399994
4  ept2 2025-10-23 06:00:00  ...  6.250000                          284.200012

[5 rows x 6 columns]
```

{% endtab %}
{% endtabs %}

### Polygons

{% tabs %}
{% tab title="Example (Python)" %}

```python
query = {
    "models": ["ept2"],
    "geo": {
        "type": "polygon",
        "value": [
            [47.3, 8.0],  # Southwest corner
            [47.6, 8.0],  # Northwest corner
            [47.6, 8.8],  # Northeast corner
            [47.3, 8.8],  # Southeast corner
            [47.3, 8.0],  # Close the polygon (same as first point)
        ],  # Polygon around Zurich region
    },
    "variables": [
        "air_temperature_at_height_level_2m",
    ],
    "init_time": "latest",
    "prediction_timedelta": [0],  # IC only
    "order_by": [
        "model",
        "init_time",
        "prediction_timedelta",
        "latitude",
        "longitude",
    ],
}

# Query parameters for arrow format and credit limit
params = {"format": "arrow", "request_credit_limit": 100}
response = requests.post(url, headers=headers, json=query, params=params)
response.raise_for_status()

# Read arrow format response
arrow_buffer = pa.py_buffer(response.content)
with pa_ipc.open_stream(arrow_buffer) as reader:
    table = reader.read_all()
df = table.to_pandas()
print(f"✅ Retrieved {len(df)} rows for polygon")
print(df.head())
return df
```

{% endtab %}

{% tab title="Output" %}

```
✅ Retrieved 40 rows for polygon
  model           init_time  ... longitude  air_temperature_at_height_level_2m
0  ept2 2025-10-23 06:00:00  ...  8.000000                          285.100006
1  ept2 2025-10-23 06:00:00  ...  8.083333                          284.600006
2  ept2 2025-10-23 06:00:00  ...  8.166667                          284.200012
3  ept2 2025-10-23 06:00:00  ...  8.250000                          283.899994
4  ept2 2025-10-23 06:00:00  ...  8.333333                          283.800018

[5 rows x 6 columns]
```

{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.jua.ai/api-v2/query-engine/examples/regional-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
