> ## Documentation Index
> Fetch the complete documentation index at: https://docs-v2.ard.co/llms.txt
> Use this file to discover all available pages before exploring further.

# API Examples

> Example requests for querying ModMS API

## Basic Queries

### Single Variable Query

Get cloud cover for a location:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20GFS.ATM.TCDC&time=[now%20TO%201762355295]&location=(32.0000,%2035.000)"
```

**Decoded:**

```
fields=time | GFS.ATM.TCDC
time=[now TO 1762355295]
location=(32.0000, 35.000)
```

### Query with Time Step Interpolation

Get hourly temperature data using STEP for time interpolation:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20location%20|%20GEM.GND2M.TMP&time=[now%20TO%201766620800%20STEP%2060%20minutes]&location=(31,%2035)"
```

**Decoded:**

```
fields=time | location | GEM.GND2M.TMP
time=[now TO 1766620800 STEP 60 minutes]
location=(31, 35)
```

<Note>
  **STEP 60 minutes** performs time interpolation to get hourly data points between available model timesteps.
</Note>

### List Available Models

Get list of available models and their last update time:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=model%20|%20last_updated&from=models"
```

### Multiple Variables

Query multiple variables at once:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20GFS.GND2M.TMP%20|%20GFS.GND2M.RH%20|%20GFS.GND10M.UGRD&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

**Decoded:**

```
fields=time | GFS.GND2M.TMP | GFS.GND2M.RH | GFS.GND10M.UGRD
time=[now TO 1762355295]
location=(32.0, 35.0)
```

### Specific Time Range

Query data for a specific time range:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20ICON.SFC.APCP.HR&time=[1762344000%20TO%201762620800]&location=(31.5,%2035.5)"
```

**Decoded:**

```
fields=time | ICON.SFC.APCP.HR
time=[1762344000 TO 1762620800]
location=(31.5, 35.5)
```

## Mathematical Expression Examples

### Model Merging

Merge multiple models with fallback:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20merged_temp&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `merged_temp` expression: `merge(WRFME.ISO850HPA.TMP, GFS.ISO850HPA.TMP) - 273.15`

### Model Averaging

Average values from multiple models:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20avg_temp&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `avg_temp` expression: `avg(GFS.ISO500HPA.TMP, UK10.ISO500HPA.TMP) - 273.15`

### Wind Speed Calculation

Calculate wind speed from U and V components:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20wind_speed&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `wind_speed` expression: `speed(GFS.GND10M.UGRD, GFS.GND10M.VGRD)`

### Wind Direction Calculation

Calculate wind direction from U and V components:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20wind_dir&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `wind_dir` expression: `dir(GFS.GND10M.UGRD, GFS.GND10M.VGRD)`

### Conditional Expression

Use conditional logic based on conditions:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20dust_prob&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `dust_prob` expression: `(LSM.LSM == 0 && speed(GFS.GND10M.UGRD, GFS.GND10M.VGRD) > 7 && GFS.GND2M.RH < 60 && GFS.SFC.APCP.HR <= 0) ? (min(speed(GFS.GND10M.UGRD, GFS.GND10M.VGRD) / 7 * 0.5, 1.0) * GFS.GND2M.RH < 40 ? 100 : (GFS.GND2M.RH * -2.5 + 200)) : 0`

### Model Median

Get median from multiple models:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20median_wind&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `median_wind` expression: `median(speed(EC25.GND10M.UGRD, EC25.GND10M.VGRD), speed(GFS.GND10M.UGRD, GFS.GND10M.VGRD), speed(ICON.GND10M.UGRD, ICON.GND10M.VGRD))`

### Relative Humidity Calculation

Calculate relative humidity from temperature and dewpoint:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20rh&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `rh` expression: `rh(GEM.GND2M.TMP, GEM.GND2M.DPT)`

### Time-Weighted Merge

Merge models based on data freshness:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20merged_wind&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `merged_wind` expression: `cmerge(time, EC25.GND10M.UGRD, EC25.LASTTIME, ICON.GND10M.UGRD, ICON.LASTTIME, GFS.GND10M.UGRD, GFS.LASTTIME)`

### Consensus from Multiple Models

Get consensus from multiple model runs:

```bash theme={null}
curl "http://modms.devops.arabiaweather.com/q?fields=time%20|%20consensus_precip&time=[now%20TO%201762355295]&location=(32.0,%2035.0)"
```

Where `consensus_precip` expression: `consensus(EC25.SFC.APCP.HR*1000, UK10.SFC.TPRATE.HR, GFS.SFC.APCP.HR, ICON.SFC.TPRATE.HR)`

## Response Format

The API returns JSON data with the requested fields:

```json theme={null}
{
  "time": [1762355200, 1762358800, ...],
  "location": [[32.0, 35.0], [32.0, 35.0], ...],
  "GFS.ATM.TCDC": [45.2, 48.5, ...]
}
```

## Related Documentation

* [Query Guide](/data-ai/modms/querying) - Complete guide to query syntax and capabilities
* [ModMS Overview](/data-ai/modms) - System overview
* [ModMS Architecture](/data-ai/modms/architecture) - System architecture
