Weather API Documentation

Getting Started
Base URL:
BASE_URL
https://weather-api-7qxy.onrender.com/api/v2

Authentication

All API requests require an API key to be included in the request headers:

const axios = require('axios');

const config = {
  method: 'GET',
  url: 'https://weather-api-7qxy.onrender.com/api/v2/current',
  headers: { 
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  params: {
  "city": "London"
}
};

axios(config)
  .then(response => console.log(JSON.stringify(response.data)))
  .catch(error => console.log(error));
Get Current Weather
GET /current

Parameters

  • city* - string - City name
  • key* - string - Your API key

Headers

{'Accept': 'application/json', 'x-api-key': 'YOUR_API_KEY'}

Example Request

GET /current?key=YOUR_API_KEY&city=London

Sample Response

{
  "location": {
    "name": "London",
    "region": "City of London, Greater London",
    "country": "United Kingdom",
    "lat": 51.52,
    "lon": -0.11,
    "tz_id": "Europe/London",
    "localtime_epoch": 1682859732,
    "localtime": "2023-04-30 14:35"
  },
  "current": {
    "last_updated_epoch": 1682859100,
    "last_updated": "2023-04-30 14:25",
    "temp_c": 15,
    "temp_f": 59,
    "is_day": 1,
    "condition": {
      "text": "Partly cloudy",
      "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png",
      "code": 1003
    },
    "wind_mph": 9.4,
    "wind_kph": 15.1,
    "wind_degree": 250,
    "wind_dir": "WSW",
    "pressure_mb": 1012,
    "pressure_in": 29.88,
    "precip_mm": 0,
    "precip_in": 0,
    "humidity": 67,
    "cloud": 25,
    "feelslike_c": 14.1,
    "feelslike_f": 57.3,
    "vis_km": 10,
    "vis_miles": 6,
    "uv": 4,
    "gust_mph": 10.5,
    "gust_kph": 16.9
  }
}
Get Weather Forecast
GET /forecast

Parameters

  • city* - string - City name
  • days - number - Number of days (1-7)
  • key* - string - Your API key

Headers

{'Accept': 'application/json', 'x-api-key': 'YOUR_API_KEY'}

Example Request

GET /forecast?key=YOUR_API_KEY&city=London&days=3

Sample Response

{
  "location": {
    "name": "London",
    "region": "City of London, Greater London",
    "country": "United Kingdom",
    "lat": 51.52,
    "lon": -0.11,
    "tz_id": "Europe/London",
    "localtime_epoch": 1682859732,
    "localtime": "2023-04-30 14:35"
  },
  "current": {
    "last_updated_epoch": 1682859100,
    "last_updated": "2023-04-30 14:25",
    "temp_c": 15,
    "temp_f": 59,
    "is_day": 1,
    "condition": {
      "text": "Partly cloudy",
      "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png",
      "code": 1003
    },
    "wind_mph": 9.4,
    "wind_kph": 15.1,
    "wind_degree": 250,
    "wind_dir": "WSW",
    "pressure_mb": 1012,
    "pressure_in": 29.88,
    "precip_mm": 0,
    "precip_in": 0,
    "humidity": 67,
    "cloud": 25,
    "feelslike_c": 14.1,
    "feelslike_f": 57.3,
    "vis_km": 10,
    "vis_miles": 6,
    "uv": 4,
    "gust_mph": 10.5,
    "gust_kph": 16.9
  },
  "forecast": {
    "forecastday": [
      {
        "date": "2023-04-30",
        "date_epoch": 1682812800,
        "day": {
          "maxtemp_c": 16.2,
          "maxtemp_f": 61.2,
          "mintemp_c": 8.7,
          "mintemp_f": 47.7,
          "avgtemp_c": 12.4,
          "avgtemp_f": 54.3,
          "maxwind_mph": 11.9,
          "maxwind_kph": 19.1,
          "totalprecip_mm": 0,
          "totalprecip_in": 0,
          "avgvis_km": 10,
          "avgvis_miles": 6,
          "avghumidity": 66,
          "daily_will_it_rain": 0,
          "daily_chance_of_rain": 0,
          "daily_will_it_snow": 0,
          "daily_chance_of_snow": 0,
          "condition": {
            "text": "Partly cloudy",
            "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png",
            "code": 1003
          },
          "uv": 4
        },
        "astro": {
          "sunrise": "05:45 AM",
          "sunset": "08:15 PM",
          "moonrise": "03:42 PM",
          "moonset": "04:10 AM",
          "moon_phase": "Waxing Gibbous",
          "moon_illumination": "75"
        },
        "hour": [
          {
            "time_epoch": 1682812800,
            "time": "2023-04-30 00:00",
            "temp_c": 10.1,
            "temp_f": 50.2,
            "is_day": 0,
            "condition": {
              "text": "Clear",
              "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png",
              "code": 1000
            },
            "wind_mph": 5.1,
            "wind_kph": 8.2,
            "wind_degree": 180,
            "wind_dir": "S",
            "pressure_mb": 1015,
            "pressure_in": 29.97,
            "precip_mm": 0,
            "precip_in": 0,
            "humidity": 80,
            "cloud": 10,
            "feelslike_c": 9.4,
            "feelslike_f": 48.9,
            "windchill_c": 9.4,
            "windchill_f": 48.9,
            "heatindex_c": 10.1,
            "heatindex_f": 50.2,
            "dewpoint_c": 6.7,
            "dewpoint_f": 44.1,
            "will_it_rain": 0,
            "chance_of_rain": 0,
            "will_it_snow": 0,
            "chance_of_snow": 0,
            "vis_km": 10,
            "vis_miles": 6,
            "gust_mph": 6,
            "gust_kph": 9.7,
            "uv": 1
          }
        ]
      }
    ]
  }
}