PHPackages                             rakibdevs/openweather-laravel-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rakibdevs/openweather-laravel-api

ActiveLibrary[API Development](/categories/api)

rakibdevs/openweather-laravel-api
=================================

Laravel package to connect https://openweathermap.org/ to get customized weather data for any location on the globe immediately

v2.0.0(1mo ago)7654.2k↓38.1%9MITPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4CI passing

Since Jan 9Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/RakibDevs/openweather-laravel-api)[ Packagist](https://packagist.org/packages/rakibdevs/openweather-laravel-api)[ RSS](/packages/rakibdevs-openweather-laravel-api/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (8)Versions (16)Used By (0)

Laravel [Open Weather](https://openweathermap.org/) API
-------------------------------------------------------

[](#laravel-open-weather-api)

[![Packagist](https://camo.githubusercontent.com/3db2f61286183e6dbea96ebb3bb300e0a0ca9d3b613a80513c78b009439e3ed3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)](https://camo.githubusercontent.com/3db2f61286183e6dbea96ebb3bb300e0a0ca9d3b613a80513c78b009439e3ed3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)[![GitHub stars](https://camo.githubusercontent.com/9d3a95bb9ebf076677e0d08d83c3cad5456619a219f8460fd82fb5f1bbbae0e8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)](https://github.com/rakibdevs/openweather-laravel-api/stargazers)[![GitHub forks](https://camo.githubusercontent.com/411213d1aa7be70aac0aedabfebc5afcc8e97b099472992f4b432507eca5a0ec/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)](https://github.com/rakibdevs/openweather-laravel-api/network)[![GitHub issues](https://camo.githubusercontent.com/73fff5a13370537a516e610e9326f24f8e2b1204f0702a7ccdcab64ea0646e34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)](https://github.com/rakibdevs/openweather-laravel-api/issues)[![GitHub license](https://camo.githubusercontent.com/38e1ce62814e1c31c75a830d645bba1d6c51949efbbc93d2cd061a5277f0d744/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72616b6962646576732f6f70656e776561746865722d6c61726176656c2d617069)](https://github.com/rakibdevs/openweather-laravel-api/blob/master/LICENSE)

Laravel OpenWeather API (openweather-laravel-api) is a Laravel package to connect Open Weather Map APIs (  ) and access free API services (current weather, weather forecast, weather history) easily.

Supported APIs
--------------

[](#supported-apis)

APIsGet data by[Current Weather](https://openweathermap.org/current)By city name, city ID, geographic coordinates, ZIP code[One Call API](https://openweathermap.org/api/one-call-api)By geographic coordinates[4 Day 3 Hour Forecast](https://openweathermap.org/forecast5)By city name, city ID, geographic coordinates, ZIP code[5 Day Historical](https://openweathermap.org/api/one-call-api#history)By geographic coordinates[Air Pollution](https://openweathermap.org/api/air-pollution)By geographic coordinates[Geocoding API](https://openweathermap.org/api/geocoding-api)By geographic coordinatesRequirements
------------

[](#requirements)

Package versionPHPLaravel`^2.0`8.0 – 8.48, 9, 10, 11, 12`^1.0` (legacy)7.2 – 8.06, 7, 8Installation
------------

[](#installation)

Install the package through [Composer](http://getcomposer.org). On the command line:

```
composer require rakibdevs/openweather-laravel-api

```

Configuration
-------------

[](#configuration)

If Laravel &gt; 7, no need to add provider

Add the following to your `providers` array in `config/app.php`:

```
'providers' => [
    // ...
    RakibDevs\Weather\WeatherServiceProvider::class,
],
'aliases' => [
    //...
    'Weather' => RakibDevs\Weather\Weather::class,
];
```

Add API key and desired language in `.env`

```
OPENWEATHER_API_KEY=
OPENWEATHER_API_LANG=en

```

> If your existing `.env` uses the older misspelled `OPENWAETHER_API_KEY` / `OPENWAETHER_API_LANG`, those are still honored as a fallback, so no change is required to keep working.

Publish the required package configuration file using the artisan command:

```
	$ php artisan vendor:publish

```

Edit the `config/openweather.php` file and modify the `api_key` value with your Open Weather Map api key.

```
	return [
	    'api_key' 	        => env('OPENWEATHER_API_KEY', ''),
    	    'onecall_api_version' => '2.5',
            'historical_api_version' => '2.5',
            'forecast_api_version' => '2.5',
            'pollution_api_version' => '2.5',   // legacy misspelled 'polution_api_version' is still honored
            'geo_api_version' => '1.0',
	    'lang' 		=> env('OPENWEATHER_API_LANG', 'en'),
	    'date_format'       => 'm/d/Y',
	    'time_format'       => 'h:i A',
	    'day_format'        => 'l',
	    'temp_format'       => 'c',        // c for celcius, f for farenheit, k for kelvin
	    'cache_enabled'     => env('OPENWEATHER_CACHE_ENABLED', false),
	    'cache_ttl'         => env('OPENWEATHER_CACHE_TTL', 600),  // seconds
	];
```

Now you can configure API version from config as [One Call API](https://openweathermap.org/price) is upgraded to version 3.0. Please set available api version in config.

Usage
-----

[](#usage)

Here you can see some example of just how simple this package is to use.

```
use RakibDevs\Weather\Weather;

$wt = new Weather();

$info = $wt->getCurrentByCity('dhaka');    // Get current weather by city name
```

#### Using the Facade (optional)

[](#using-the-facade-optional)

The package auto-registers a `Weather` facade, so you can also call it statically:

```
use RakibDevs\Weather\Facades\Weather;

$info = Weather::getCurrentByCity('dhaka');
```

Or resolve it from the container / via dependency injection:

```
$info = app('weather')->getCurrentByCity('dhaka');
```

#### Per-call options (optional)

[](#per-call-options-optional)

Override units or language for a single request without touching the config. These setters are fluent and reset automatically after each request:

```
// c = metric, f = imperial, k = standard
$info = $wt->units('f')->lang('bn')->getCurrentByCity('dhaka');
```

#### Response caching (optional)

[](#response-caching-optional)

Enable caching in `config/openweather.php` (or via `.env`) to reduce API calls. It is **off by default**, so existing behavior is unchanged:

```
OPENWEATHER_CACHE_ENABLED=true
OPENWEATHER_CACHE_TTL=600
```

#### Fluent response (optional)

[](#fluent-response-optional)

By default every method returns the raw `stdClass` response (unchanged). Call `->fluent()`to get a `WeatherResponse` wrapper instead — it keeps the familiar property access (`$res->main->temp` still works) and adds dot-notation access, conversions and helpers. The flag applies to a single request and then resets:

```
$res = $wt->fluent()->getCurrentByCity('dhaka');

// backward-compatible property access still works
$res->main->temp;

// dot-notation access with default
$res->get('main.temp');
$res->get('weather.0.description', 'n/a');
$res->has('wind.gust');

// convenience getters (current-weather shape)
$res->temperature();     // main.temp
$res->feelsLike();       // main.feels_like
$res->humidity();        // main.humidity
$res->windSpeed();       // wind.speed
$res->condition();       // weather.0.main
$res->description();     // weather.0.description
$res->city();            // name
$res->country();         // sys.country
$res->icon();            // weather.0.icon
$res->iconUrl();         // https://openweathermap.org/img/wn/04d@2x.png

// conversions & collections
$res->toArray();
$res->toJson();
$res->raw();                       // the original stdClass, untouched
$res->collect('list');             // Illuminate\Support\Collection (for list responses)

// ArrayAccess (dot notation supported)
$res['main.temp'];
```

`->fluent()` composes with the other setters, e.g. `$wt->fluent()->units('f')->getCurrentByCity('dhaka')`.

### [Current weather](https://openweathermap.org/current)

[](#current-weather)

Access current weather data for any location on Earth including over 200,000 cities! [OpenWeather](https://openweathermap.org/) collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations

```
// By city name
$info = $wt->getCurrentByCity('dhaka');

// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->getCurrentByCity(1185241);

// By Zip Code - string with country code
$info = $wt->getCurrentByZip('94040,us');  // If no country code specified, us will be default

// By coordinates : latitude and longitude
$info = $wt->getCurrentByCord(23.7104, 90.4074);
```

#### Output:

[](#output)

```
{
  "coord": {
    "lon": 90.4074
    "lat": 23.7104
  }
  "weather":[
    0 => {
      "id": 721
      "main": "Haze"
      "description": "haze"
      "icon": "50d"
    }
  ]
  "base": "stations"
  "main": {
    "temp": 26
    "feels_like": 25.42
    "temp_min": 26
    "temp_max": 26
    "pressure": 1009
    "humidity": 57
  }
  "visibility": 3500
  "wind": {
    "speed": 4.12
    "deg": 280
  }
  "clouds": {
    "all": 85
  }
  "dt": "01/09/2021 04:16 PM"
  "sys": {
    "type": 1
    "id": 9145
    "country": "BD"
    "sunrise": "01/09/2021 06:42 AM"
    "sunset": "01/09/2021 05:28 PM"
  }
  "timezone": 21600
  "id": 1185241
  "name": "Dhaka"
  "cod": 200
}

```

### [One Call API](https://openweathermap.org/api/one-call-api)

[](#one-call-api)

Make just one API call and get all your essential weather data for a specific location with OpenWeather One Call API.

```
// By coordinates : latitude and longitude
$info = $wt->getOneCallByCord(23.7104, 90.4074);
```

### [4 Day 3 Hour Forecast](https://openweathermap.org/forecast5)

[](#4-day-3-hour-forecast)

4 day forecast is available at any location or city. It includes weather forecast data with 3-hour step.

```
// By city name
$info = $wt->get3HourlyByCity('dhaka');

// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
$info = $wt->get3HourlyByCity(1185241);

// By Zip Code - string with country code
$info = $wt->get3HourlyByZip('94040,us');  // If no country code specified, us will be default

// By coordinates : latitude and longitude
$info = $wt->get3HourlyByCord(23.7104, 90.4074);
```

### [5 Day Historical](https://openweathermap.org/api/one-call-api#history)

[](#5-day-historical)

Get access to historical weather data for the previous 5 days.

```
// By coordinates : latitude, longitude and date
$info = $wt->getHistoryByCord(23.7104, 90.4074, '2020-01-09');
```

### [Air Pollution](https://openweathermap.org/api/one-call-api#history)

[](#air-pollution)

Air Pollution API provides current, forecast and historical air pollution data for any coordinates on the globe

Besides basic Air Quality Index, the API returns data about polluting gases, such as Carbon monoxide (CO), Nitrogen monoxide (NO), Nitrogen dioxide (NO2), Ozone (O3), Sulphur dioxide (SO2), Ammonia (NH3), and particulates (PM2.5 and PM10).

Air pollution forecast is available for 5 days with hourly granularity. Historical data is accessible from 27th November 2020.

```
// By coordinates : latitude, longitude and date
$info = $wt->getAirPollutionByCord(23.7104, 90.4074);
```

### [Geocoding API](https://openweathermap.org/api/one-call-api#history)

[](#geocoding-api)

Geocoding API is a simple tool that we have developed to ease the search for locations while working with geographic names and coordinates. -&gt; Direct geocoding converts the specified name of a location or area into the exact geographical coordinates; -&gt; Reverse geocoding converts the geographical coordinates into the names of the nearby locations.

```
// By city name
$info = $wt->getGeoByCity('dhaka');

// By coordinates : latitude, longitude and date
$info = $wt->getGeoByCity(23.7104, 90.4074);
```

### [Free API Limitations](https://openweathermap.org/api/one-call-api#history)

[](#free-api-limitations)

- 60 calls/minute
- 1,000,000 calls/month
- 1000 calls/day when using Onecall requests

License
-------

[](#license)

Laravel Open Weather API is licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance90

Actively maintained with recent releases

Popularity44

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 89.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~200 days

Recently: every ~373 days

Total

11

Last Release

46d ago

Major Versions

v1.9.0 → v2.0.02026-07-03

PHP version history (4 changes)v1.0PHP ^7

v1.1PHP ^7.0|^8.0

v1.5PHP ^7.2|^7.3|^7.4|^8.0

v2.0.0PHP ^8.0|^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d789cf937c914cb8a2ce0c513840be4c4558007bb36433509496587d1989fdb?d=identicon)[rakibdevs](/maintainers/rakibdevs)

---

Top Contributors

[![rakibdevs](https://avatars.githubusercontent.com/u/44586913?v=4)](https://github.com/rakibdevs "rakibdevs (57 commits)")[![Waghabond](https://avatars.githubusercontent.com/u/62872555?v=4)](https://github.com/Waghabond "Waghabond (4 commits)")[![joshuadegier](https://avatars.githubusercontent.com/u/2580917?v=4)](https://github.com/joshuadegier "joshuadegier (3 commits)")

---

Tags

apilaravelopenweathermap-apipackageweatherapilaravelweatheropen-weather

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rakibdevs-openweather-laravel-api/health.svg)

```
[![Health](https://phpackages.com/badges/rakibdevs-openweather-laravel-api/health.svg)](https://phpackages.com/packages/rakibdevs-openweather-laravel-api)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
