All Projects → rakibdevs → openweather-laravel-api

rakibdevs / openweather-laravel-api

Licence: MIT license
Laravel OpenWeather API is a Laravel package to connect Open Weather Map API and get wether data in your own format laravel app.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to openweather-laravel-api

weather-mobile
A simple GTK4 weather app to play with rust and PinePhone development. I just needed a weather app that scaled properly...
Stars: ✭ 15 (-72.22%)
Mutual labels:  weather, openweathermap-api
OWM-JAPIs
Java APIs for OpenWeatherMap.org
Stars: ✭ 14 (-74.07%)
Mutual labels:  openweathermap-api
Profiles
👍 Make JavaScript Great Again
Stars: ✭ 238 (+340.74%)
Mutual labels:  weather
clouds
🌦 A weather app for iOS, written in SwiftUI.
Stars: ✭ 26 (-51.85%)
Mutual labels:  weather
mpxday
mpxday是基于mpx开发的天气预报微信小程序
Stars: ✭ 3 (-94.44%)
Mutual labels:  weather
MMM-forecast-io
Forecast.io Module for MagicMirror
Stars: ✭ 58 (+7.41%)
Mutual labels:  weather
Wttr.in
⛅ The right way to check the weather
Stars: ✭ 16,345 (+30168.52%)
Mutual labels:  weather
raspi-weather
a weather application for the raspberry pi and the Pimorioni Inky pHAT.
Stars: ✭ 59 (+9.26%)
Mutual labels:  weather
Weather Shield
Barometric pressure, temperature, humidity and light sensing weather shield for Arduino.
Stars: ✭ 62 (+14.81%)
Mutual labels:  weather
Weather-app
This is a simple not complicated weather app, that I have built using openweather API, promises, await/async, and WebPack. you can find the live link below don't hesitate to check your local weather status at any point in time.
Stars: ✭ 18 (-66.67%)
Mutual labels:  weather
Weather-SwiftUI
A weather app that uses the Dark Sky API built using SwiftUI! Get the current weather for a particular location and check out the 5-day forecast!
Stars: ✭ 107 (+98.15%)
Mutual labels:  weather
Champ
A Telegram bot combined with python to serve some basic functions like weather, music charts, cricket score and much more.
Stars: ✭ 22 (-59.26%)
Mutual labels:  weather
433MHz Tx Rx
Arduino based 433MHz Tx and Rx combo using Manchester protocol
Stars: ✭ 27 (-50%)
Mutual labels:  weather
gis4wrf
QGIS toolkit 🧰 for pre- and post-processing 🔨, visualizing 🔍, and running simulations 💻 in the Weather Research and Forecasting (WRF) model 🌀
Stars: ✭ 137 (+153.7%)
Mutual labels:  weather
FLOB-weather
F(or)L(ack)O(f a)B(etter) Weather is a small CLI app that let you ask for weather forecasts directly from you terminal using OpenWeather API.
Stars: ✭ 19 (-64.81%)
Mutual labels:  weather
Ruby Scripts
A collection of ruby scripts for those who live in the command line
Stars: ✭ 234 (+333.33%)
Mutual labels:  weather
AnimatedEnvironmentLayer
A custom arcgis js api layer to display GRIB data formatted as json as animated particles on a canvas
Stars: ✭ 41 (-24.07%)
Mutual labels:  weather
nexradaws
This python package is designed to provide query and download capabilities to the NEXRAD archive available on Amazon Web Services (AWS). https://aws.amazon.com/public-datasets/nexrad/
Stars: ✭ 32 (-40.74%)
Mutual labels:  weather
rain-geojson-sg
Straight-forward API server to convert rain area radar images (Singapore) to GeoJSON
Stars: ✭ 15 (-72.22%)
Mutual labels:  weather
rainviewer-api-example
How to use RainViewer API: simple HTML + JS code which render an animated weather radar overlay on the map
Stars: ✭ 56 (+3.7%)
Mutual labels:  weather

Laravel Open Weather API

Packagist GitHub stars GitHub forks GitHub issues GitHub license

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

Supported APIs

APIs Get data by
Current Weather By city name, city ID, geographic coordinates, ZIP code
One Call API By geographic coordinates
4 Day 3 Hour Forecast By city name, city ID, geographic coordinates, ZIP code
5 Day Historical By geographic coordinates
Air Pollution By geographic coordinates
Geocoding API By geographic coordinates

Installation

Install the package through Composer. On the command line:

composer require rakibdevs/openweather-laravel-api

Configuration

If Laravel > 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

OPENWAETHER_API_KEY=
OPENWAETHER_API_LANG=en

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('OPENWAETHER_API_KEY', ''),
    	    'onecall_api_version' => '2.5',
            'historical_api_version' => '2.5',
            'forecast_api_version' => '2.5',
            'polution_api_version' => '2.5',
            'geo_api_version' => '1.0',
	    'lang' 		=> env('OPENWAETHER_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
	];

Now you can configure API version from config as One Call API is upgraded to version 3.0. Please set available api version in config.

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

Current weather

Access current weather data for any location on Earth including over 200,000 cities! OpenWeather 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:

{
  "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

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

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

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

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

Geocoding API is a simple tool that we have developed to ease the search for locations while working with geographic names and coordinates. -> Direct geocoding converts the specified name of a location or area into the exact geographical coordinates; -> 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

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

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].