thomasboom89 / openweathermap-one-call-api
A wrapper for Openweathermap One Call Api v1
Requires
- php: >=8.2
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/simple-cache: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.46
- guzzlehttp/guzzle: ^7.8
- php-http/mock-client: ^1.6
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
- roave/security-advisories: dev-latest
- symfony/cache: ^v7.0
This package is auto-updated.
Last update: 2024-05-16 19:21:44 UTC
README
A wrapper for Openweathermap One Call Api v1 -> Link.
Attention!
I am not owner or maintainer of the API (https://openweathermap.org/api). This is only a wrapper for it. You need to get an api-key from their site to use the api.
Requirement
You need a working environment with php >= 8.2 and composer.
Installation
composer require thomasboom89/openweathermap-one-call-api
Usage
Create an instance of the OneCallApi
$httpClient = new Client(); $httpFactory = new HttpFactory(); $owmoca = new OneCallApi("YOUR-API-KEY", $httpClient, $httpFactory); // Optional use caching interface $pool = new ArrayAdapter(); $cache = new Psr16Cache($pool); $owmoca = new OneCallApi("YOUR-API-KEY", $httpClient, $httpFactory, $cache, 240);
Now you can use it to make a request
// lat , lon , language , unitsystem try { $forecast = $owmoca->getForecast(-78.944450, 19.458971, OneCallApi\Language::German, OneCallApi\Unit::Metric); } catch (Exception $exception){ // handle exception }
You will receive a forecast object
var_dump($forecast);
FAQ
Q: Which language is currently supported?
A: You have to use Enum Thomasboom89\OpenWeatherMap\OneCallApi\Language
(If a language is missing, please open an issue)
Q: Which unitsystem is currently supported?
A: You have to use Enum Thomasboom89\OpenWeatherMap\OneCallApi\Unit \
License
Openweathermap One Call API Copyright (C) 2023 ThomasBoom89. MIT license.
Openweathermap One Call API includes several third-party Open-Source libraries, which are licensed under their own respective Open-Source licenses.
See composer license
for complete list of depending libraries.