API Documentation

Welcome to our API Documentation! Our API provides real-time weather information for cities around the world.

Endpoint

/api/weather?city=Mogadishu

To use our API, simply make a GET request to the endpoint above by replacing Mogadishu with the name of the city you want weather data for.

Code Examples

import requests

def get_weather(city):
    response = requests.get(
        f'http://localhost:3000/api/weather?city={city}'
    )
    return response.json()

print(get_weather('Mogadishu'))

Response Format

Successful Response (200 OK)

{
  "success": true,
  "timestamp": "2024-11-04/23:30:56 UTC+3",
  "developer": {
    "website": "https://apitools.pages.dev"
  },
  "source": "Weather API",
  "data": {
    "city": "Mogadishu",
    "country": "🇸🇴 Somalia",
    "temperature": "28°C",
    "feels_like": "32°C",
    "weather": "Clear sky",
    "humidity": "75%",
    "wind_speed": "5.2 m/s",
    "cloud_coverage": "10%"
  },
  "processingTime": "0.45s"
}

Error Response (400 Bad Request)

{
  "success": false,
  "timestamp": "2024-11-09/21:50:19 UTC+3",
  "developer": {
    "website": "https://apitools.pages.dev"
  },
  "source": "Weather API",
  "description": "Failed to fetch weather data",
  "data": {
    "error": "City parameter is required to fetch weather data"
  }
}

Error Response (404 Not Found)

{
  "success": false,
  "timestamp": "2024-11-09/21:50:19 UTC+3",
  "developer": {
    "website": "https://apitools.pages.dev"
  },
  "source": "Weather API",
  "description": "Failed to fetch weather data",
  "data": {
    "error": "City not found"
  }
}

Response Fields

FieldDescription
cityThe name of the city
countryThe name of the country with flag emoji
temperatureCurrent temperature in degrees Celsius
feels_likeTemperature that feels like, factoring in weather conditions
weatherDescription of current weather condition
humidityCurrent humidity level as a percentage
wind_speedCurrent wind speed in meters per second
cloud_coveragePercentage of sky covered by clouds