A php api to parse weather data from This api tries to normalise and abstract the data and remove inconsistencies.

Installs: 16 901

Dependents: 4

Stars: 113

Watchers: 17

Forks: 34

Open Issues: 3

v2.0.11 2016-01-31 15:07 UTC


A php api to parse weather data from The api tries to normalise and abstract the data and remove inconsistencies.

Build Status Scrutinizer Quality Score Code Coverage


For example code and how to use this api, please take a look into Examples_*.php files and run them in your browser.

  • Examples_Current.php Shows how to receive the current weather.
  • Examples_Forecast.php Shows how to receive weather forecasts.
  • Examples_History.php Shows how to receive weather history.
  • Examples_Cache.php Shows how to implement a cache.

Notice: The api is neither maintained by OpenWeatherMap, nor their official php api.


I'm very happy if you open pull requests or issues to help making this API more awesome.


This library can be found on Packagist. The recommended way to install this is through composer.

Edit your composer.json and add:

    "require": {
        "cmfcmf/openweathermap-php-api": "~2.0"

And install dependencies:

$ curl -sS | php
$ php composer.phar install

Example call

use Cmfcmf\OpenWeatherMap;
use Cmfcmf\OpenWeatherMap\Exception as OWMException;

// Must point to composer's autoload file.

// Language of data (try your own language here!):
$lang = 'de';

// Units (can be 'metric' or 'imperial' [default]):
$units = 'metric';

// Get OpenWeatherMap object. Don't use caching (take a look into Example_Cache.php to see how it works).
$owm = new OpenWeatherMap();

try {
    $weather = $owm->getWeather('Berlin', $units, $lang);
} catch(OWMException $e) {
    echo 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
    echo "<br />\n";
} catch(\Exception $e) {
    echo 'General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').';
    echo "<br />\n";

echo $weather->temperature;


MIT — Please see the LICENSE file distributed with this source code for further information regarding copyright and licensing.

Please check out the following links to read about the usage policies and the license of OpenWeatherMap before using the service.