Weather API Documentation

Welcome to the Weather API documentation. This API provides current weather data and forecasts for locations worldwide.

Base URL

https://api.weather.com/v1

Authentication

To use this API, you need to include your API key in the header of each request:

X-API-Key: your_api_key_here

Endpoints

GET /current

Get current weather data for a specific location.

Parameters:

Name Type Description
lat float Latitude of the location
lon float Longitude of the location

Example Response:

{
  "location": {
    "name": "New York",
    "country": "US",
    "lat": 40.7128,
    "lon": -74.0060
  },
  "current": {
    "temperature": 22.5,
    "humidity": 65,
    "wind_speed": 5.2,
    "wind_direction": "NE",
    "condition": "Partly cloudy"
  }
}
    

GET /forecast

Get weather forecast for a specific location.

Parameters:

Name Type Description
lat float Latitude of the location
lon float Longitude of the location
days integer Number of days to forecast (max 7)

Example Response:

{
  "location": {
    "name": "London",
    "country": "UK",
    "lat": 51.5074,
    "lon": -0.1278
  },
  "forecast": [
    {
      "date": "2023-06-01",
      "max_temp": 18.5,
      "min_temp": 12.3,
      "condition": "Sunny"
    },
    {
      "date": "2023-06-02",
      "max_temp": 20.1,
      "min_temp": 13.7,
      "condition": "Partly cloudy"
    }
  ]
}
    

Error Responses

The API uses standard HTTP response codes to indicate the success or failure of an API request. In case of an error, the response body will contain more information about the error.

Example Error Response:

{
  "error": {
    "code": 401,
    "message": "Invalid API key"
  }
}
  

Rate Limiting

The API is rate limited to 1000 requests per day per API key. If you exceed this limit, you will receive a 429 Too Many Requests response.

Support

If you have any questions or need assistance, please contact our support team at support@weather-api.com.