Skip to content

Commit 12e47a8

Browse files
committed
Update Readme
1 parent 6f88495 commit 12e47a8

File tree

1 file changed

+167
-2
lines changed

1 file changed

+167
-2
lines changed

README.md

Lines changed: 167 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,174 @@
1-
## Laravel Open Weather API
1+
## Laravel [Open Weather](https://openweathermap.org/) API
22

33

4+
## Supported APIs
5+
| Operation | English Input | |
6+
| --- | --- |
7+
| [Current Weather](https://openweathermap.org/current) | By city name, city ID, geographic coordinates, ZIP code |
8+
| [One Call API](https://openweathermap.org/api/one-call-api) | By geographic coordinates|
9+
| [4 Day 3 Hour Forecast](https://openweathermap.org/forecast5) | By city name, city ID, geographic coordinates, ZIP code |
10+
| [5 Day Historical](https://openweathermap.org/api/one-call-api#history) | By geographic coordinates |
11+
| [Air Pollution](https://openweathermap.org/api/air-pollution) | By geographic coordinates |
12+
| [Geocoding API](https://openweathermap.org/api/geocoding-api) | By geographic coordinates |
13+
14+
15+
## Installation
16+
17+
Install the package through [Composer](http://getcomposer.org).
18+
On the command line:
19+
20+
```
21+
22+
23+
```
24+
25+
26+
## Configuration
27+
If Laravel > 7, no need to add provider
28+
29+
Add the following to your `providers` array in `config/app.php`:
30+
31+
```php
32+
'providers' => [
33+
// ...
34+
35+
RakibDevs\Weather\WeatherServiceProvider::class,
36+
],
37+
'aliases' => [
38+
//...
39+
'Weather' => RakibDevs\Weather\Weather::class,
40+
];
41+
42+
43+
```
44+
45+
46+
Publish the required package configuration file using the artisan command:
47+
```
48+
$ php artisan vendor:publish
49+
```
50+
Edit the `config/openweather.php` file and modify the `api_key` value with your Open Weather Map api key.
51+
```
52+
return [
53+
'api_key' => 'ae9f7b6a0cfc2563ec1d24f3c267ad42',
54+
'lang' => 'en',
55+
'date_format' => 'm/d/Y',
56+
'time_format' => 'h:i A',
57+
'day_format' => 'l',
58+
'temp_format' => 'c' // c for celcius, f for farenheit, k for kelvin
59+
];
60+
```
61+
62+
63+
## Usage
64+
Here you can see some example of just how simple this package is to use.
65+
66+
```php
67+
use RakibDevs\Weather\Weather;
68+
69+
$wt = new Weather();
70+
71+
$info = $wt->getCurrentByCity('dhaka'); // Get current weather by city name
72+
73+
74+
```
75+
76+
### [Current weather](https://openweathermap.org/current)
77+
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
78+
79+
```php
80+
81+
// By city name
82+
$info = $wt->getCurrentByCity('dhaka');
83+
84+
// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
85+
$info = $wt->getCurrentByCity(1185241);
86+
87+
// By Zip Code - string with country code
88+
$info = $wt->getCurrentByZip('94040,us'); // If no country code specified, us will be default
89+
90+
// By coordinates : latitude and longitude
91+
$info = $wt->getCurrentByCord(23.7104, 90.4074);
92+
93+
```
94+
95+
#### Output:
96+
```
97+
{#294 ▼
98+
+"coord": {#296 ▼
99+
+"lon": 90.4074
100+
+"lat": 23.7104
101+
}
102+
+"weather": array:1 [▼
103+
0 => {#280 ▼
104+
+"id": 721
105+
+"main": "Haze"
106+
+"description": "haze"
107+
+"icon": "50d"
108+
}
109+
]
110+
+"base": "stations"
111+
+"main": {#290 ▼
112+
+"temp": 26
113+
+"feels_like": 25.42
114+
+"temp_min": 26
115+
+"temp_max": 26
116+
+"pressure": 1009
117+
+"humidity": 57
118+
}
119+
+"visibility": 3500
120+
+"wind": {#284 ▼
121+
+"speed": 4.12
122+
+"deg": 280
123+
}
124+
+"clouds": {#283 ▼
125+
+"all": 85
126+
}
127+
+"dt": "01/09/2021 04:16 PM"
128+
+"sys": {#281 ▼
129+
+"type": 1
130+
+"id": 9145
131+
+"country": "BD"
132+
+"sunrise": "01/09/2021 06:42 AM"
133+
+"sunset": "01/09/2021 05:28 PM"
134+
}
135+
+"timezone": 21600
136+
+"id": 1185241
137+
+"name": "Dhaka"
138+
+"cod": 200
139+
}
140+
141+
```
142+
143+
### [One Call API](https://openweathermap.org/api/one-call-api)
144+
Make just one API call and get all your essential weather data for a specific location with OpenWeather One Call API.
145+
146+
```php
147+
// By coordinates : latitude and longitude
148+
$info = $wt->getOneCallByCord(23.7104, 90.4074);
149+
150+
```
151+
152+
### [4 Day 3 Hour Forecast](https://openweathermap.org/forecast5)
153+
4 day forecast is available at any location or city. It includes weather forecast data with 3-hour step.
154+
155+
```php
156+
// By city name
157+
$info = $wt->get3HourlyByCity('dhaka');
158+
159+
// By city ID - download list of city id here http://bulk.openweathermap.org/sample/
160+
$info = $wt->get3HourlyByCity(1185241);
161+
162+
// By Zip Code - string with country code
163+
$info = $wt->get3HourlyByZip('94040,us'); // If no country code specified, us will be default
164+
165+
// By coordinates : latitude and longitude
166+
$info = $wt->get3HourlyByCord(23.7104, 90.4074);
167+
168+
```
169+
4170

5171

6172
## License
7173

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

0 commit comments

Comments
 (0)