Introduction
In today's fast-paced world, accurate weather data is crucial for various applications, from travel planning to agriculture. The Weather Data APIs from Zyla API Hub provide developers with the tools they need to integrate real-time weather information into their applications. This blog post will guide you through testing the Weather Data API using Postman, covering installation steps, authentication setup, request examples, environment variables, error handling, and example responses.
Step 1: Access the Weather Data API Page on Zyla API Hub
To begin, navigate to the Weather Data API page on the Zyla API Hub. Here, you will find detailed information about the various weather APIs available, including the Weather Forecast API, Yahoo Weather Information API, Geographical Weather API, and more.
Step 2: Start Free Trial or Subscribe
Once you are on the API page, you can either start a free trial or subscribe to the service. This will give you access to the API and its features.
Step 3: Download the Postman Collection
After subscribing, look for the option to "Run in Postman." Click on it to download the Postman collection, which contains pre-configured requests for the Weather Data API.
Step 4: Open Your Postman Workspace
Launch Postman and open your workspace. This is where you will import the downloaded collection and start testing the API.
Step 5: Import the Downloaded Postman Collection
In Postman, click on the "Import" button and select the downloaded collection file. This will add the Weather Data API requests to your workspace.
Step 6: Confirm Collection Import and Access Key
Once the collection is imported, confirm that the Zyla API Hub collection has been successfully added. Your access key should already be included in the collection, allowing you to send requests immediately.
Testing the Weather Data API
Now that you have set up Postman, you can start testing the Weather Data API. Below, we will explore the key features of the Weather Forecast API, along with examples and explanations.
Weather Forecast API
The Weather Forecast API provides access to a wide range of weather data, including current conditions, hourly and daily forecasts, and historical data. This API is essential for developers looking to integrate weather information into their applications.
Key Features and Capabilities
1. Get Weather by City
To use this endpoint, simply insert a city name in the parameter. This feature is valuable for applications that need to provide localized weather information.
Example Response:
{
"coord": {
"lon": -89.1028,
"lat": 30.438
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01n"
}
],
"base": "stations",
"main": {
"temp": 53.69,
"feels_like": 50.31,
"temp_min": 47.64,
"temp_max": 55.38,
"pressure": 1011,
"humidity": 33
},
"visibility": 10000,
"wind": {
"speed": 10.36,
"deg": 310
},
"clouds": {
"all": 0
},
"dt": 1705116489,
"sys": {
"type": 1,
"id": 4248,
"country": "US",
"sunrise": 1705064049,
"sunset": 1705101271
},
"timezone": -21600,
"id": 4429197,
"name": "Landon",
"cod": 200
}
This response includes key fields such as temperature, humidity, and weather conditions, which can be used to inform users about the current weather in their location.
2. Get Weather by Longitude and Latitude
This endpoint allows users to retrieve weather data by specifying geographic coordinates. This is particularly useful for applications that require precise location data.
Example Response:
{
"coord": {
"lon": -89.102,
"lat": 30.43
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"base": "stations",
"main": {
"temp": 307.89,
"feels_like": 313.21,
"temp_min": 307.04,
"temp_max": 309.09,
"pressure": 1016,
"humidity": 50
},
"visibility": 10000,
"wind": {
"speed": 4.12,
"deg": 190
},
"clouds": {
"all": 0
},
"dt": 1691001805,
"sys": {
"type": 2,
"id": 2003455,
"country": "US",
"sunrise": 1690974904,
"sunset": 1691023811
},
"timezone": -18000,
"id": 4450687,
"name": "West Gulfport",
"cod": 200
}
This response provides detailed weather information based on the specified coordinates, making it ideal for location-based services.
3. Get Weather Forecast
This feature allows users to obtain a 5-day weather forecast by providing latitude and longitude. This is essential for applications that require future weather predictions.
Example Response:
{
"cod": "200",
"message": 0,
"cnt": 40,
"list": [
{
"dt": 1737450000,
"main": {
"temp": 273.77,
"feels_like": 268.44,
"temp_min": 272.66,
"temp_max": 273.77,
"pressure": 1032,
"sea_level": 1032,
"grnd_level": 1030,
"humidity": 34,
"temp_kf": 1.11
},
"weather": [
{
"id": 804,
"main": "Clouds",
"description": "overcast clouds",
"icon": "04n"
}
],
"clouds": {
"all": 100
},
"wind": {
"speed": 6.09,
"deg": 26,
"gust": 10.97
},
"visibility": 10000,
"pop": 0,
"sys": {
"pod": "n"
},
"dt_txt": "2025-01-21 09:00:00"
}
]
}
This response includes a detailed forecast for the next five days, allowing users to plan their activities accordingly.
Yahoo Weather Information API
The Yahoo Weather Information API provides accurate weather data, including current conditions and forecasts. This API is essential for applications that require reliable weather information.
Key Features and Capabilities
1. Weather by City
To use this endpoint, specify the name of a city and the desired temperature unit (Fahrenheit or Celsius). This flexibility allows users to customize their requests based on their preferences.
Example Response:
{
"location": {
"city": "Sunnyvale",
"woeid": 2502265,
"country": "United States",
"lat": 37.371609,
"long": -122.038254,
"timezone_id": "America/Los_Angeles"
},
"current_observation": {
"pubDate": 1696006274,
"wind": {
"chill": 68,
"direction": "SSE",
"speed": 2
},
"atmosphere": {
"humidity": 75,
"visibility": 9.01,
"pressure": 1011.9
},
"astronomy": {
"sunrise": "7:02 AM",
"sunset": "6:55 PM"
},
"condition": {
"temperature": 65,
"text": "Cloudy",
"code": 26
}
},
"forecasts": [
{
"day": "Fri",
"date": 1696003200,
"high": 75,
"low": 60,
"text": "Partly Cloudy",
"code": 30
}
]
}
This response provides current weather conditions and a forecast, making it useful for applications that need to inform users about the weather.
Geographical Weather API
The Geographical Weather API offers forecasts and current observations based on geographic coordinates. This API is valuable for applications that require precise weather information tailored to specific locations.
Key Features and Capabilities
1. Weather Information
To use this endpoint, indicate a latitude and longitude in the parameters. This feature is essential for applications that need to provide weather data based on specific geographic locations.
Example Response:
{
"location": {
"region": "wrh",
"latitude": "38.07",
"longitude": "-120.65",
"elevation": "1398",
"wfo": "STO",
"timezone": "P|Y|8",
"areaDescription": "6 Miles W Angels CA"
},
"currentObservation": {
"id": "ESPC1",
"name": "BANNER ROAD",
"observationDate": "07 Aug 10:13 AM PDT",
"temperature": 99,
"dewpoint": 38,
"relativeHumidity": "12%",
"windSpeed": 4,
"windDirection": "S"
}
}
This response provides real-time weather observations based on geographic coordinates, making it ideal for location-based services.
Weather by City API
The Weather by City API allows users to access real-time and forecast weather information by simply entering the name of a city. This API is essential for applications that need to provide localized weather data.
Key Features and Capabilities
1. Get Weather
To use this endpoint, enter the name of a city in the parameter. This feature is valuable for applications that need to provide users with accurate weather information based on their location.
Example Response:
{
"success": true,
"data": {
"city": "Bandra Kurla Complex, Maharashtra",
"current_weather": "Haze",
"temp": "31",
"expected_temp": "Day34 Night30",
"insight_heading": "Rain",
"insight_description": "Rain ending around 11:30 pm.",
"wind": "14km/h",
"humidity": "82%",
"visibility": "3.22 km",
"uv_index": "0 of 11",
"aqi": "56",
"aqi_remark": "Satisfactory",
"aqi_description": "May cause minor breathing discomfort to sensitive people.",
"last_update": "21:44 IST",
"bg_image": "https://s.w-x.co/WeatherImages_Web/WeatherImage_Haze-night_2.jpg?crop=16:9&width=800&format=pjpg&auto=webp&quality=70"
}
}
This response provides comprehensive weather data, including current conditions and forecasts, which can be used to inform users about the weather in their city.
Location Based Weather API
The Location Based Weather API provides weather data and forecasts based on user-defined locations. This API is valuable for applications that require accurate weather information tailored to specific areas.
Key Features and Capabilities
1. Weather by City
To use this endpoint, indicate a city in the parameter. This feature is essential for applications that need to provide localized weather data.
Example Response:
{
"base": "stations",
"clouds": {
"all": 0
},
"cod": 200,
"coord": {
"lat": 52.5244,
"lon": 13.4105
},
"dt": 1695845800,
"id": 2950159,
"main": {
"feels_like": 293.17,
"humidity": 76,
"pressure": 1007,
"temp": 293.13,
"temp_max": 295.46,
"temp_min": 289.31
},
"name": "Berlin",
"sys": {
"country": "DE",
"id": 2011538,
"sunrise": 1695790789,
"sunset": 1695833709,
"type": 2
},
"timezone": 7200,
"visibility": 10000,
"weather": [
{
"description": "clear sky",
"icon": "01n",
"id": 800,
"main": "Clear"
}
],
"wind": {
"deg": 120,
"speed": 3.6
}
}
This response provides detailed weather information for a specified city, making it useful for applications that need to inform users about local weather conditions.
Wind API
The Wind API provides real-time wind insights based on specific geographic coordinates. This API is essential for applications that require accurate wind data for planning outdoor activities.
Key Features and Capabilities
1. Winds by Location
To use this endpoint, indicate a country along with the location. This feature is valuable for applications that need to provide localized wind data.
Example Response:
{
"request": {
"type": "City",
"query": "London, United Kingdom",
"language": "en",
"unit": "m"
},
"location": {
"name": "London",
"country": "United Kingdom",
"region": "City of London, Greater London",
"lat": "51.517",
"lon": "-0.106",
"timezone_id": "Europe/London",
"localtime": "2024-09-25 14:35",
"localtime_epoch": 1727274900,
"utc_offset": "1.0"
},
"current": {
"observation_time": "01:35 PM",
"temperature": 17,
"weather_code": 116,
"weather_icons": [
"https://cdn.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png"
],
"weather_descriptions": [
"Partly cloudy"
],
"wind_speed": 10,
"wind_degree": 178,
"wind_dir": "S",
"pressure": 998,
"precip": 0.2,
"humidity": 68,
"cloudcover": 75,
"feelslike": 17,
"uv_index": 3,
"visibility": 10
}
}
This response provides current wind conditions for a specified location, making it useful for applications that require real-time wind data.
Accurate Weather Forecasts by ZIP Code API
This API provides detailed weather information based on ZIP codes, making it essential for applications that need to deliver localized weather data.
Key Features and Capabilities
1. Get Weather By Zip
To use this endpoint, simply insert the ZIP code of the city of your choice. This feature is valuable for applications that need to provide weather data based on postal codes.
Example Response:
{
"City": "New York City",
"State": "NY",
"TempF": "69.0",
"TempC": "20.6",
"Weather": "Fog/Mist",
"WindMPH": "0.0",
"WindDir": "North",
"RelativeHumidity": "87",
"VisibilityMiles": "6.00",
"AirQualityIndex": "48",
"AirQualityCode": "1",
"AirQuality": "Good",
"Sunrise": "NA",
"Sunset": "NA",
"DaylightHours": "NA",
"DaylightMinutes": "NA",
"Code": "Success",
"Credits": "499406810"
}
This response provides comprehensive weather data based on ZIP code, making it useful for applications that need to inform users about local weather conditions.
Weather By City Name API
The Weather By City Name API provides real-time weather information for cities worldwide by simply passing the city name. This API is essential for applications that need to provide accurate weather data.
Key Features and Capabilities
1. Get Weather By City Name
To use this endpoint, simply pass the city name as a parameter. This feature is valuable for applications that need to provide localized weather data quickly.
Example Response:
{
"location": {
"name": "Toronto",
"region": "Ontario",
"country": "Canada",
"lat": 43.67,
"lon": -79.42,
"tz_id": "America/Toronto",
"localtime_epoch": 1726752786,
"localtime": "2024-09-19 09:33"
},
"current": {
"last_updated_epoch": 1726752600,
"last_updated": "2024-09-19 09:30",
"temp_c": 21.3,
"temp_f": 70.3,
"is_day": 1,
"condition": {
"text": "Sunny",
"icon": "//cdn.weatherapi.com/weather/64x64/day/113.png",
"code": 1000
},
"wind_mph": 4.9,
"wind_kph": 7.9,
"wind_degree": 52,
"wind_dir": "NE",
"pressure_mb": 1016,
"pressure_in": 30.01,
"precip_mm": 0,
"precip_in": 0,
"humidity": 83,
"cloud": 0,
"feelslike_c": 21.3,
"feelslike_f": 70.3,
"windchill_c": 17.8,
"windchill_f": 64.1,
"heatindex_c": 17.8,
"heatindex_f": 64,
"dewpoint_c": 16.4,
"dewpoint_f": 61.4,
"vis_km": 14,
"vis_miles": 8,
"uv": 4,
"gust_mph": 6.6,
"gust_kph": 10.6
}
}
This response provides accurate and up-to-date weather information for a specified city, making it useful for applications that need to inform users about local weather conditions.
Conclusion
Testing the Weather Data API from Zyla API Hub using Postman is a straightforward process that allows developers to integrate accurate weather information into their applications. By following the steps outlined in this guide, you can quickly set up your environment and start sending requests to the API. The various features offered by the Weather Data APIs provide valuable data that can enhance user experiences and improve decision-making across multiple sectors.
For more information, visit the official documentation pages for the Weather Data APIs on Zyla API Hub.