PHPackages                             mrcnpdlk/weather-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. mrcnpdlk/weather-api

ActiveLibrary

mrcnpdlk/weather-api
====================

Weather API and air quality for Poland

v1.0.1(7y ago)28MITPHPPHP &gt;=7.0

Since Jan 7Pushed 7y agoCompare

[ Source](https://github.com/mrcnpdlk/weather-api)[ Packagist](https://packagist.org/packages/mrcnpdlk/weather-api)[ RSS](/packages/mrcnpdlk-weather-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

WEATHER API - (not only) Polish weather + air quality
=====================================================

[](#weather-api---not-only-polish-weather--air-quality)

Contents
========

[](#contents)

1. [Installation](#installation)
2. [Basic usage](#basic-usage)
    1. [Cache](#cache)
    2. [Logger](#log)
3. [External sources](#external-sources)
    1. [Chief Inspectorate of Environmental Protection](#gios)
    2. [Airly](#airly)
    3. [Open Weather Map](#owm)
4. [API Usage](#api-usage)
    1. [Create instance](#create-instance)
    2. [Available methods](#methods)
    3. [Examples](#examples)

Installation
------------

[](#installation)

Install the latest version with [composer](https://packagist.org/packages/mrcnpdlk/weather-api)

```
composer require mrcnpdlk/weather-api
```

Basic usage
-----------

[](#basic-usage)

### Cache

[](#cache)

Library supports Cache bundles based on [PSR-16](http://www.php-fig.org/psr/psr-16/) standard.

For below example was used [phpfastcache/phpfastcache](https://github.com/PHPSocialNetwork/phpfastcache) V7. `phpfastcache/phpfastcache` supports a lot of endpoints, i.e. `Files`, `Sqlite`, `Redis` and many other. More information about using cache and configuration it you can find in this [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki).

```
    /**
     * Cache in system files
     */
    $oFilesConfig = new \Phpfastcache\Drivers\Files\Config();
    $oFilesConfig->setPath(sys_get_temp_dir())->setDefaultTtl(60);
    $oInstanceCacheFiles = new \Phpfastcache\Helper\Psr16Adapter('files', $oFilesConfig);
    /**
     * Cache in Redis
     */
    $oRedisConfig = new \Phpfastcache\Drivers\Redis\Config();
    $oRedisConfig
        ->setHost('localhost')
        ->setPort(6379)
        ->setDefaultTtl(60)
        ;
    $oInstanceCacheRedis = new \Phpfastcache\Helper\Psr16Adapter('redis', $oRedisConfig);
```

### Log

[](#log)

Library also supports logging packages based on [PSR-3](http://www.php-fig.org/psr/psr-3/) standard, i.e. very popular [monolog/monolog](https://github.com/Seldaek/monolog).

```
$oInstanceLogger = new \Monolog\Logger('name_of_my_logger');
$oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        \Psr\Log\LogLevel::DEBUG
    )
)->pushProcessor(new \Monolog\Processor\PsrLogMessageProcessor());
```

External sources
----------------

[](#external-sources)

### GIOS

[](#gios)

[GIOS](http://powietrze.gios.gov.pl/pjp/home) (Chief Inspectorate of Environmental Protection - Główny Inspektorat Ochrony Środowiska) provide [API](http://powietrze.gios.gov.pl/pjp/content/api) without any authentication.

### Airly

[](#airly)

[Airly](https://airly.eu/en/) builds networks of air quality sensors that can be deployed across entire cities or counties. If you want to use external data using this API you have to get the free Token key from [here](https://developer.airly.eu/) .

### OWM

[](#owm)

[Open Weather Map](http://openweathermap.org/) is well know project for weather and forecast. To use it, get the free Token Key from [here](http://openweathermap.org/appid) .

API usage
---------

[](#api-usage)

### Create instance

[](#create-instance)

```
$oClient = new \mrcnpdlk\Weather\Client();
$oClient
    ->setCacheInstance($oInstanceCacheFiles)
    ->setLoggerInstance($oInstanceLogger)
    ->setAirlyConfig('AIRLY_TOKEN')  // not required but recommended
    ->setOWMConfig('OWM_TOKEN')  // not required but recommended
;
$oApi = new \mrcnpdlk\Weather\Api($oClient);
```

By default API uses:

- current geo location found using public IP of machine where script is run
- current date of machine where script is run

We are able to change location calling `setLocation()` method.

```
use mrcnpdlk\Weather\NativeModel\GeoPoint;

$oApi->setLocation(new GeoPoint(51.758158,19.544377));
```

### Methods

[](#methods)

NameDescriptionUses external sources?getAddress()Getting address using revers geocodenogetSunSchedule()Getting surise, sunset, twilight timing etcnogetNearestGiosStation()Getting nearest GIOS stationnogetUVIndex()UV Indexyes, OWMgetWeather()weatheryes, OWM### Examples

[](#examples)

#### getAddress()

[](#getaddress)

```
mrcnpdlk\Weather\Model\Address Object
(
    [countryCode] => pl
    [province] => łódzkie
    [commune] => Łódź
    [place] => Łódź
    [neighbourhood] => Katedralna
    [street] => Wincentego Tymienieckiego
    [homeNr] => 16
    [postalCode] => 90-365
)

```

#### getSunSchedule()

[](#getsunschedule)

Method can give inappropriate results for location near pole.

```
mrcnpdlk\Weather\Model\SunSchedule Object
(
    [sunrise] => 07:46:57
    [sunset] => 15:50:12
    [dayDuration] => 8:03
    [transit] => 11:48:34
    [civilTwilightBegin] => 07:07:27
    [civilTwilightEnd] => 16:29:42
    [nauticalTwilightBegin] => 06:24:41
    [nauticalTwilightEnd] => 17:12:27
    [astronomicalTwilightBegin] => 05:44:05
    [astronomicalTwilightEnd] => 17:53:03
)

```

#### getUVIndex()

[](#getuvindex)

```
0.43

```

#### getNearestGiosStation()

[](#getnearestgiosstation)

```
mrcnpdlk\Weather\NativeModel\Gios\Station Object
(
    [id] => 10058
    [stationName] => Łódź-Jana Pawła II 15
    [dateStart] => 2015-10-27 00:00:00
    [dateEnd] =>
    [gegrLat] => 51.754613
    [gegrLon] => 19.434925
    [addressStreet] => al. Jana Pawła II 15
    [city] => mrcnpdlk\Weather\NativeModel\Gios\City Object
        (
            [id] => 516
            [name] => Łódź
            [commune] => mrcnpdlk\Weather\NativeModel\Gios\Commune Object
                (
                    [communeName] => Łódź
                    [districtName] => Łódź
                    [provinceName] => ŁÓDZKIE
                )

        )

    [distance] => 2253.495
)

```

`mrcnpdlk\Weather\NativeModel\Gios\Station` has implemented two methods:

NameDescriptiongetAirQualityIndex()Return air quality indexgetSensors()Return list of available sensors for stationFor each sensor `getData()` method return list of historical measurement data.Native API
----------

[](#native-api)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~78 days

Total

3

Last Release

2890d ago

Major Versions

v0.1.0 → v1.0.02018-06-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9b157a438a90ac875df96b1b332262157576dad35ab4a49ab7837dd1ed4bd2b?d=identicon)[mrcnpdlk](/maintainers/mrcnpdlk)

---

Top Contributors

[![mrcnpdlk](https://avatars.githubusercontent.com/u/22945316?v=4)](https://github.com/mrcnpdlk "mrcnpdlk (39 commits)")

---

Tags

air qualityweatherpogodaairlygios

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mrcnpdlk-weather-api/health.svg)

```
[![Health](https://phpackages.com/badges/mrcnpdlk-weather-api/health.svg)](https://phpackages.com/packages/mrcnpdlk-weather-api)
```

###  Alternatives

[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[cmfcmf/openweathermap-php-api

A PHP API to parse weather data from OpenWeatherMap.org. This wrapper tries to normalise and abstract the data and remove inconsistencies.

3471.3M7](/packages/cmfcmf-openweathermap-php-api)[allyans3/steam-market-api-v2

Steam Market API v2

1937.3k](/packages/allyans3-steam-market-api-v2)[rakibdevs/openweather-laravel-api

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

7648.2k](/packages/rakibdevs-openweather-laravel-api)[guhelski/forecast-php

Drop dead simple Dark Sky API wrapper in PHP

42143.8k](/packages/guhelski-forecast-php)[vemcogroup/laravel-weather

Weather package for Laravel to use different providers to get weather info

5525.0k](/packages/vemcogroup-laravel-weather)

PHPackages © 2026

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