This repository has been archived by the owner. It is now read-only.
OpenWeatherMap Library
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Endroid OpenWeatherMap

By endroid

Latest Stable Version Build Status Total Downloads Monthly Downloads License

OpenWeatherMap helps making requests to the OpenWeatherMap API, without having to bother too much about passing your API key and building requests. The only thing you need is the API key (APPID) which you can find after registration on the website.

More info about custom parameters in the official API docs:

use Endroid\OpenWeatherMap\Client;

$apiKey = '...';
$client = new Client($apiKey);

// Retrieve the current weather for Breda
$weather = $client->getWeather('Breda,nl');

// Or retrieve the weather using the generic query method
$response = $client->query('weather', ['q' => 'Breda,nl']);
$weather = json_decode($response->getContent());

// You can also retrieve a N days forecast
$forecast = $client->getForecast('Breda,nl', 7);

Symfony integration

Register the Symfony bundle in the kernel.

// app/AppKernel.php

public function registerBundles()
    $bundles = [
        // ...
        new Endroid\OpenWeatherMap\Bundle\EndroidOpenWeatherMapBundle(),

The default parameters can be overridden via the configuration.

    api_key: '...'
    units: 'metric'

Now you can retrieve the client as follows.

$client = $this->get('endroid.open_weather_map.client');


Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.


This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.