How to get weather at current location
Solution 1
I have personally used this API its free and you can retrieve weather forecast for any location via postcode, zipcode or latitude and longitude
**NOTE:**The Local Weather API returns weather data in XML, JSON and CSV format and contains weather elements like temperature, precipitation (rainfall), weather description, weather icon and wind speed.
**UPDATE:**The www.worldweatheronline.com/ api is not free anymore.
Try these
Solution 2
let me tell you what you should NOT use.. Google API ( it has been stopped )
http://thenextweb.com/google/2012/08/28/did-google-just-quietly-kill-private-weather-api/
Then, you have other options like
Yahoo Weather API
http://developer.yahoo.com/weather/
Eg.. To get the forecast for Paris, France, with degrees Celsius and other metric units: http://weather.yahooapis.com/forecastrss?w=615702&u=c
for other example visit the link http://developer.yahoo.com/weather/#examples
WunderGround Weather API
http://www.wunderground.com/weather/api/
Another Good Alternate is Open Weather Map API , it supports JSON output by passing just the latitude and longitude of the location.
http://openweathermap.org/wiki/API/JSON_API
Solution 3
Here's a collection of weather APIs that you can experiment with via your browser and then generate source code for in your favorite language:
https://live.temboo.com/library/keyword/weather/
Full disclosure: I work at Temboo.
Solution 4
I have personally used OpenWeather API. its totally free and you can retrieve weather forecast for any location via city name, zipcode or latitude and longitude etc.
<?php
$city = 'london';
$jsonfile = file_get_contents( 'http://api.openweathermap.org/data/2.5/weather?q=' . $city . '&units=metric&lang=en&appid=c0c4a4b4047b97ebc5948ac9c48c0559' );
$jsondata = json_decode( $jsonfile );
$temp = $jsondata->main->temp;
$pressure = $jsondata->main->pressure;
$mintemp = $jsondata->main->temp_min;
$maxtemp = $jsondata->main->temp_max;
$wind = $jsondata->wind->speed;
$humidity = $jsondata->main->humidity;
$desc = $jsondata->weather[0]->description;
$maind = $jsondata->weather[0]->main;
$currentTime = time();
?>
<style>
body {
font-family: Arial;
font-size: 0.95em;
color: #929292;
}
.report-container {
border: #E0E0E0 1px solid;
padding: 20px 40px 40px 40px;
border-radius: 2px;
width: 550px;
margin: 0 auto;
}
.weather-icon {
vertical-align: middle;
margin-right: 20px;
}
.weather-forecast {
color: #212121;
font-size: 1.2em;
font-weight: bold;
margin: 20px 0px;
}
span.min-temperature {
margin-left: 15px;
color: #929292;
}
.time {
line-height: 25px;
}
</style>
<body>
<div class="report-container">
<h2><?php echo $jsondata->name; ?> Weather Status</h2>
<div class="time">
<div><?php echo date( 'l g:i a', $currentTime ); ?></div>
<div><?php echo date( 'jS F, Y', $currentTime ); ?></div>
<div><?php echo $desc; ?></div>
</div>
<div class="weather-forecast">
<img
src="http://openweathermap.org/img/w/<?php echo $jsondata->weather[0]->icon; ?>.png"
class="weather-icon" /> <?php echo $mintemp; ?>°C<span
class="min-temperature"><?php echo $maxtemp; ?>°C</span>
</div>
<div class="time">
<div>Humidity: <?php echo $humidity; ?> %</div>
<div>Wind: <?php echo $wind; ?> km/h</div>
</div>
</div>
</body>
Solution 5
OpenWeatherMap is the best weather open API that you can use: https://openweathermap.org/api
- It provides free weather data and forecast API suitable for any cartographic services like web and smartphones applications
- It uses JSON/XML formats to provide weather data for your app.
- It offers a wide array of useful weather-related information including current weather, historical weather, forecast, wind, clouds, weather station data, and more
- How can we get weather information for a selected location? Openweathermap provides different two modes to look for a city. One uses name pattern and another using geo-coordinates.
- Free to use
Here is a sample app android-openweathermap-app
Tuan Vu
Updated on July 05, 2022Comments
-
Tuan Vu almost 2 years
Possible duplicate:
Get weather update of current location?
How can I get the weather in current location from Latitude and Longitude?
I'm developing an app, it can update weather at current location. I have googled and found how to use Google API. But now Google API not available, and I used Yahoo weather instead.
My questions:
How to get weather use Yahoo Weather API
Tutorial or Source Code