placehold.cloud

Weather API

Usage Guide

Get accurate weather data with our powerful API. Here's how to get started:

Basic Usage

https://placehold.cloud/w?city=London&country=GB

This request will return weather data for London, UK.

Query Parameters

  • city: Name of the city (required)
  • country: Two-letter country code (required)
  • units: Units of measurement (metric, imperial, or standard) (optional)
  • lang: Two-letter language code (optional)
  • forecast_days: Number of forecast days (1-7) (optional)
  • include_hourly: Include hourly forecast (boolean) (optional)
  • include_alerts: Include weather alerts (boolean) (optional)
  • include_historical: Include historical data (boolean) (optional)
  • include_uv_index: Include UV index (boolean) (optional)

Response Format

{
    "status": "success",
    "data": {
        "city": "City Name",
        "country": "Country Code",
        "current": {
            // Current weather data
        },
        "forecast": [
            // Forecast data for requested days
        ],
        "air_quality": {
            // Air quality data
        },
        "sunrise": "YYYY-MM-DD HH:MM:SS",
        "sunset": "YYYY-MM-DD HH:MM:SS",
        "hourly": [
            // Hourly forecast data (if requested)
        ],
        "alerts": [
            // Weather alerts (if requested)
        ],
        "historical": {
            // Historical weather data (if requested)
        },
        "uv_index": 0.0 // UV index (if requested)
    },
    "units": "metric",
    "lang": "en",
    "timestamp": "YYYY-MM-DD HH:MM:SS"
}
                        

Example Usage

Here's an example of how to use the API with parameters:

https://placehold.cloud/w?city=London&country=GB&units=metric&forecast_days=3

This request will return weather data for London, UK, in metric units, with a 3-day forecast.

Error Handling

In case of an error, the API will return a JSON response with an error message:

{
    "status": "error",
    "message": "Error description"
}
                        

API Limits

To ensure fair usage, this API is rate-limited. Please adhere to the following limits:

  • 60 requests per minute
  • 1000 requests per day