> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.etera.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.etera.dev/_mcp/server.

# Get weather forecast for a city

GET https://api.etera.dev/context/weather/forecast


Retrieve weather forecast information for a specified location using WeatherAPI.com.

**Features:**
- Multi-day weather forecasts (1-7 days)
- Support for city names or coordinates (lat/lon)
- Detailed daily weather information including min/max temperatures
- Precipitation chance and wind information
- Support for multiple temperature units
- Authentication required for all requests

**Location Input:**
- **City-based**: Provide `city` parameter (e.g., "London", "New York")
- **Coordinate-based**: Provide `lat` and `lon` parameters (e.g., 51.5074, -0.1278)
- Either city OR coordinates must be provided

**Forecast Information:**
- Daily high/low temperatures
- Weather conditions and descriptions
- Humidity and wind speed
- Precipitation probability
- Weather icons for UI display

**Authentication:**
- Requires valid Bearer token
- Test tokens available for development: `test-jwt-token`, `agent-jwt-token`
- Production tokens verified with external auth service

**Rate Limits:**
- Subject to WeatherAPI.com rate limits
- 10-second timeout for external API calls

**Examples:**
- 3-day forecast for London: `/api/context/weather/forecast?city=London`
- 7-day forecast for New York: `/api/context/weather/forecast?city=New%20York&days=7`
- Imperial units for Tokyo: `/api/context/weather/forecast?city=Tokyo&units=imperial&days=5`
- Coordinates: `/api/context/weather/forecast?lat=51.5074&lon=-0.1278&days=3`
        

Reference: https://docs.etera.dev/platform/context/context-api/weather/get-weather-forecast

## Authentication

- `Authorization` header (bearer token, required) — JWT token obtained from the Auth API

## Servers

- `https://api.etera.dev/context` (Production, default)
- `https://api-stage.etera.dev/context` (Staging)
- `https://api-dev.etera.dev/context` (Development)

## Request

### Query parameters

- `city` (string, optional) — City name (required if coordinates not provided)
- `country` (string, optional) — Country code for disambiguation (optional)
- `lat` (string, optional) — Latitude coordinate (required if city not provided)
- `lon` (string, optional) — Longitude coordinate (required if city not provided)
- `units` (WeatherForecastGetParametersUnits, optional) — Temperature units (default: metric)
- `days` (string, optional, default: 3) — Number of forecast days (1-7, default: 3)

### Headers

- `authorization` (string, optional) — Bearer token for authentication

## Response

### 200

Weather forecast data retrieved successfully

## Types

### WeatherForecastGetParametersUnits

- "metric"
- "imperial"
- "kelvin"

## Examples

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.etera.dev/context/weather/forecast"

querystring = {"days":"1"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.etera.dev/context/weather/forecast?days=1';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.etera.dev/context/weather/forecast?days=1"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.etera.dev/context/weather/forecast?days=1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.etera.dev/context/weather/forecast?days=1")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.etera.dev/context/weather/forecast?days=1', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.etera.dev/context/weather/forecast?days=1");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.etera.dev/context/weather/forecast?days=1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```