Weather Data API Endpoint
This guide provides step-by-step instructions for developers to retrieve weather data using the weather endpoint. By passing in a location and a date range you can receive weather for each day at that location. This can also be used when querying rates, for those steps check out the Search Query Guide.
Endpoint Details
Purpose:
Retrieve historical or forecast weather data for a specific location and date range.
Request Parameters
latitude
The latitude of the location.
longitude
Longitude of the location.
startDate
The start date in YYYY-MM-DD format.
endDate
The end date in YYYY-MM-DD format.
units
Units of measurement. Options: metric
or imperial
.
Sample Request
curl -X GET "https://api.liteapi.travel/v3.0/data/weather?latitude=37.7749&longitude=-122.4194&startDate=2025-01-03&endDate=2025-01-05&units=metric"
Response Format
Example weather data for San Francisco (latitude: 37.7749, longitude: -122.4194) for January 3, 2025 (2025-01-03). The API returns this weather data in JSON format.
⭐️ Note: Each day in the date range gets its own dailyWeather
object.
{
"weatherData": [
{
"dailyWeather": {
"date": "2025-01-03",
"units": "metric",
"cloud_cover": {
"afternoon": 41.61
},
"humidity": {
"afternoon": 87.67
},
"precipitation": {
"total": 1.92
},
"temperature": {
"min": 14.09,
"max": 16.75,
"afternoon": 14.09,
"night": 16.75,
"evening": 14.73,
"morning": 14.4
},
"pressure": {
"afternoon": 1016.84
},
"wind": {
"max": {
"speed": 6.61,
"direction": 287.15
}
}
}
}...
Response Fields
date
: The specific date for the weather data.
units
: Units of measurement used (metric or imperial).
cloud_cover
: Percentage of cloud cover during the afternoon.
humidity
: Afternoon humidity as a percentage.
precipitation
: The chance of precipitation as a percentage.
temperature
:
min
: Minimum temperature of the day.max
: Maximum temperature of the day.
afternoon
, night
, evening
, morning
: Temperature readings for different times of the day.
pressure
: Atmospheric pressure in hPa during the afternoon.
wind.max
:
speed
: Maximum wind speed (m/s or mph).direction
: Wind direction in degrees.
Implementation Notes
- Error Handling:
• Ensure valid latitude and longitude values.
• Dates must be in YYYY-MM-DD format and within a valid range.
• Handle cases where data for the requested range is not available. - Units:
• Default is metric (e.g., temperatures in °C, wind speed in m/s).
• Use imperial for temperatures in °F and wind speed in mph. - Date Range:
• Ensure that the startDate is earlier than or equal to endDate. - Parsing JSON:
• Loop through the weatherData array to extract data for each date.
Example usage
This API is a tool for accessing weather data. The closer the date is, the more reliable the weather will be, but no guarantee is offered. Integrate it into your applications for dynamic weather tracking or analysis. Possible uses include:
Complementary Hotel Suggestions:
- Upon selecting a destination, display weather forecasts for chosen dates alongside hotel listings.
- Suggest amenities at hotels (e.g., indoor pools or solariums) based on predicted weather conditions.
Activity and Itinerary Planning:
- Offer travelers itinerary suggestions optimized for weather conditions, such as rainy-day museum tours or sunny beach activities.
- Propose flexible booking options or accommodations with weather-related cancellations or rescheduling perks.
Interface Customization:
- Display dynamic themes or backgrounds in the widget/UI based on current weather (e.g., sunny skies or rainy clouds).
- Include contextual content like seasonal attire suggestions or packing lists relevant to forecasted weather.
Personalized Alerts and Recommendations:
- Enable notifications for weather changes affecting travel plans, such as severe weather alerts with suggested safety measures.
- Recommend alternate destinations when severe weather is forecasted, offering comparable hotels or activities.
Interactive Weather Maps:
- Provide users with interactive maps showing real-time weather changes, enhancing visual travel planning.
- Allow users to explore weather patterns further with detailed daily/hourly forecasts.
Enhanced Booking Experience:
- Integrate weather information at the point of booking to encourage using weather forecasts to align with expected travel conditions.
- Display insights such as "Perfect Beach Weather" or "Avoid This Date" messages to prompt quicker bookings.
Updated about 1 month ago