pyVisualCrossing 0.1.16__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyVisualCrossing
3
+ Version: 1.0.1
4
+ Summary: Gets the weather data from Visual Crossing
5
+ Home-page: https://github.com/briis/pyVisualCrossing
6
+ Author: briis
7
+ Author-email: bjarne@briis.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Development Status :: 4 - Beta
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: summary
24
+
25
+ # Python Wrapper for Visual Crossing Weather API
26
+
27
+ This Python Wrapper retrives data from the [Visual Crossing](https://www.visualcrossing.com/) API. Visual Crossing has an extensive Weather API for both historical and forecast weather data, and they have a Free Tier API Key which enables up to 1000 calls per day.
28
+
29
+ In order to get started you must create an Account with Visual Crossing and then create an API Key. You do this by accessing [this website](https://www.visualcrossing.com/weather-data-editions) and clicking on the **Free** plan. Then follow the instructions to create and account and store your key in a safe place.
30
+
31
+ ## Usage
32
+
33
+ Install the module by using this command in a terminal: `pip install pyVisualCrossing`
34
+
35
+ And then see `test_module.py` for a usage example.
36
+
37
+ ## Parameters
38
+
39
+ ```python
40
+ # Initialise the module
41
+ vcapi = VisualCrossing(
42
+ api_key,
43
+ latitude,
44
+ longitude,
45
+ days=7,
46
+ language="da"
47
+ )
48
+ ```
49
+
50
+ | Parameter | Required | Default | Description |
51
+ | --------- | -------- | ------- | ----------- |
52
+ | `api_key` | Yes | `None` | This is the API Key you signed up for from Visual Crossing. See above for instructions |
53
+ | `latitude` | Yes | `None` | Latitude for the location position |
54
+ | `longitude` | Yes | `None` | Longitude for the location position |
55
+ | `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
56
+ | `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
57
+ | `session` | No | `None` | An `aiohttp.ClientSession` to reuse for the async function. If not supplied, a session is created and closed automatically. |
58
+
59
+ For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
60
+
61
+ ## Fetching Data
62
+
63
+ Once initialised, call either the synchronous or the async method to retrieve data. Both return a single `ForecastData` object (or `None` if the request failed), holding the current conditions plus a daily and an hourly forecast list.
64
+
65
+ ```python
66
+ # Synchronous
67
+ data = vcapi.fetch_data()
68
+
69
+ # Async
70
+ data = await vcapi.async_fetch_data()
71
+
72
+ print(data.temperature)
73
+ for day in data.forecast_daily:
74
+ print(day.datetime, day.temperature, day.condition)
75
+
76
+ for hour in data.forecast_hourly:
77
+ print(hour.datetime, hour.temperature, hour.condition)
78
+ ```
79
+
80
+ ## Exceptions
81
+
82
+ If the API request fails, one of these exceptions (all importable from `pyVisualCrossing`) is raised:
83
+
84
+ | Exception | Description |
85
+ | --------- | ----------- |
86
+ | `VisualCrossingBadRequest` | The request was invalid (invalid dates, bad location parameter, etc.) |
87
+ | `VisualCrossingUnauthorized` | The API key is incorrect, or the account is inactive or disabled |
88
+ | `VisualCrossingTooManyRequests` | Too many daily requests for the current plan |
89
+ | `VisualCrossingInternalServerError` | Visual Crossing's servers encountered an unexpected error |
90
+ | `VisualCrossingException` | Generic base exception for failing to access the API |
91
+
92
+ ## Data
93
+
94
+ ### Current Conditions (`ForecastData`)
95
+
96
+ | Property | Description |
97
+ | -------- | ----------- |
98
+ | `datetime` | Valid time (UTC) |
99
+ | `temperature` | Air temperature |
100
+ | `apparent_temperature` | Feels-like temperature |
101
+ | `dew_point` | Dew point |
102
+ | `condition` | Weather condition text |
103
+ | `icon` | Weather condition icon id |
104
+ | `cloud_cover` | Cloud coverage (%) |
105
+ | `humidity` | Humidity (%) |
106
+ | `precipitation` | Precipitation |
107
+ | `precipitation_probability` | Probability of precipitation (%) |
108
+ | `pressure` | Sea level pressure |
109
+ | `solarradiation` | Solar radiation (W/m2) |
110
+ | `visibility` | Visibility |
111
+ | `uv_index` | UV index |
112
+ | `wind_bearing` | Wind bearing (degrees) |
113
+ | `wind_speed` | Wind speed |
114
+ | `wind_gust_speed` | Wind gust speed |
115
+ | `location_name` | Name of the location |
116
+ | `description` | Weather description |
117
+ | `snow` | Snowfall |
118
+ | `snow_depth` | Snow depth |
119
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
120
+ | `solarenergy` | Solar energy (MJ/m2) |
121
+ | `sunrise` | Sunrise time |
122
+ | `sunset` | Sunset time |
123
+ | `moon_phase` | Moon phase, as a fraction between 0 and 1 |
124
+ | `update_time` | Timestamp of when the data was fetched |
125
+ | `forecast_daily` | List of `ForecastDailyData` |
126
+ | `forecast_hourly` | List of `ForecastHourlyData` |
127
+
128
+ ### Daily Forecast (`ForecastDailyData`)
129
+
130
+ | Property | Description |
131
+ | -------- | ----------- |
132
+ | `datetime` | Valid date (UTC) |
133
+ | `temperature` | Max air temperature for the day |
134
+ | `temp_low` | Min air temperature for the day |
135
+ | `apparent_temperature` | Feels-like temperature |
136
+ | `condition` | Weather condition text |
137
+ | `icon` | Weather condition icon id |
138
+ | `cloud_cover` | Cloud coverage (%) |
139
+ | `dew_point` | Dew point |
140
+ | `humidity` | Humidity (%) |
141
+ | `precipitation` | Precipitation |
142
+ | `precipitation_probability` | Probability of precipitation (%) |
143
+ | `pressure` | Sea level pressure |
144
+ | `uv_index` | UV index |
145
+ | `wind_bearing` | Wind bearing (degrees) |
146
+ | `wind_speed` | Wind speed |
147
+ | `wind_gust` | Wind gust speed |
148
+ | `snow` | Snowfall |
149
+ | `snow_depth` | Snow depth |
150
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
151
+ | `precipitation_cover` | Percentage of the day with precipitation (%) |
152
+ | `solarradiation` | Solar radiation (W/m2) |
153
+ | `solarenergy` | Solar energy (MJ/m2) |
154
+ | `severe_risk` | Risk score of severe weather |
155
+ | `sunrise` | Sunrise time |
156
+ | `sunset` | Sunset time |
157
+ | `moon_phase` | Moon phase, as a fraction between 0 and 1 |
158
+
159
+ ### Hourly Forecast (`ForecastHourlyData`)
160
+
161
+ Only hours later than the current time are included.
162
+
163
+ | Property | Description |
164
+ | -------- | ----------- |
165
+ | `datetime` | Valid date and time (UTC) |
166
+ | `temperature` | Air temperature |
167
+ | `apparent_temperature` | Feels-like temperature |
168
+ | `condition` | Weather condition text |
169
+ | `icon` | Weather condition icon id |
170
+ | `cloud_cover` | Cloud coverage (%) |
171
+ | `dew_point` | Dew point |
172
+ | `humidity` | Humidity (%) |
173
+ | `precipitation` | Precipitation |
174
+ | `precipitation_probability` | Probability of precipitation (%) |
175
+ | `pressure` | Sea level pressure |
176
+ | `uv_index` | UV index |
177
+ | `wind_bearing` | Wind bearing (degrees) |
178
+ | `wind_speed` | Wind speed |
179
+ | `wind_gust_speed` | Wind gust speed |
180
+ | `snow` | Snowfall |
181
+ | `snow_depth` | Snow depth |
182
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
183
+ | `solarradiation` | Solar radiation (W/m2) |
184
+ | `solarenergy` | Solar energy (MJ/m2) |
185
+ | `severe_risk` | Risk score of severe weather |
186
+ | `visibility` | Visibility |
187
+
188
+ ## Languages
189
+ Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
190
+
191
+ ## Metrics
192
+ All records are returned using the *Metric* unit system. There is no conversion possible at the moment.
193
+
194
+ | Weather variable | Measurement Unit |
195
+ | ----------------------------------- | ------------------------ |
196
+ | Datetime | UTC datetime |
197
+ | Temperature, Heat Index & Wind Chill | Degrees Celcius |
198
+ | Precipitation | Millimeters |
199
+ | snow | Centimeters |
200
+ | Wind & Wind Gust | Kilometers Per Hour |
201
+ | Visibility | Kilometers |
202
+ | Pressure | Millibars (Hectopascals) |
203
+ | Solar Radiation | W/m2 |
204
+ | Solar Energy | MJ/m2 |
205
+
206
+ ## Icons
207
+ We use the Iconset *icons2*, which gives a more detailed description of the conditions.
208
+
209
+ | Icon id | Weather Conditions |
210
+ | -------------------- | ---------------------------- |
211
+ | snow | Amount of snow is greater than zero |
212
+ | snow-showers-day | Periods of snow during the day |
213
+ | snow-showers-night | Periods of snow during the night |
214
+ | thunder-rain | Thunderstorms throughout the day or night |
215
+ | thunder-showers-day | Possible thunderstorms throughout the day |
216
+ | thunder-showers-night | Possible thunderstorms throughout the night |
217
+ | rain | Amount of rainfall is greater than zero |
218
+ | showers-day | Rain showers during the day |
219
+ | showers-night | Rain showers during the night |
220
+ | fog | Visibility is low (lower than one kilometer or mile) |
221
+ | wind | Wind speed is high (greater than 30 kph or mph) |
222
+ | cloudy | Cloud cover is greater than 90% cover |
223
+ | partly-cloudy-day | Cloud cover is greater than 20% cover during day time. |
224
+ | partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
225
+ | clear-day | Cloud cover is less than 20% cover during day time |
226
+ | clear-night | Cloud cover is less than 20% cover during night time |
@@ -0,0 +1,202 @@
1
+ # Python Wrapper for Visual Crossing Weather API
2
+
3
+ This Python Wrapper retrives data from the [Visual Crossing](https://www.visualcrossing.com/) API. Visual Crossing has an extensive Weather API for both historical and forecast weather data, and they have a Free Tier API Key which enables up to 1000 calls per day.
4
+
5
+ In order to get started you must create an Account with Visual Crossing and then create an API Key. You do this by accessing [this website](https://www.visualcrossing.com/weather-data-editions) and clicking on the **Free** plan. Then follow the instructions to create and account and store your key in a safe place.
6
+
7
+ ## Usage
8
+
9
+ Install the module by using this command in a terminal: `pip install pyVisualCrossing`
10
+
11
+ And then see `test_module.py` for a usage example.
12
+
13
+ ## Parameters
14
+
15
+ ```python
16
+ # Initialise the module
17
+ vcapi = VisualCrossing(
18
+ api_key,
19
+ latitude,
20
+ longitude,
21
+ days=7,
22
+ language="da"
23
+ )
24
+ ```
25
+
26
+ | Parameter | Required | Default | Description |
27
+ | --------- | -------- | ------- | ----------- |
28
+ | `api_key` | Yes | `None` | This is the API Key you signed up for from Visual Crossing. See above for instructions |
29
+ | `latitude` | Yes | `None` | Latitude for the location position |
30
+ | `longitude` | Yes | `None` | Longitude for the location position |
31
+ | `days` | No | `14` | Numbers of days to retrieve forecast for. 14 days means today plus the next 14 days. On the Free plan, this is the maximum number of days |
32
+ | `language` | No | `en` | The language in which text strings should be returned. Se below for list of valid languages. |
33
+ | `session` | No | `None` | An `aiohttp.ClientSession` to reuse for the async function. If not supplied, a session is created and closed automatically. |
34
+
35
+ For an in-depth description of the Visual Crossing API, go [here](https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/)
36
+
37
+ ## Fetching Data
38
+
39
+ Once initialised, call either the synchronous or the async method to retrieve data. Both return a single `ForecastData` object (or `None` if the request failed), holding the current conditions plus a daily and an hourly forecast list.
40
+
41
+ ```python
42
+ # Synchronous
43
+ data = vcapi.fetch_data()
44
+
45
+ # Async
46
+ data = await vcapi.async_fetch_data()
47
+
48
+ print(data.temperature)
49
+ for day in data.forecast_daily:
50
+ print(day.datetime, day.temperature, day.condition)
51
+
52
+ for hour in data.forecast_hourly:
53
+ print(hour.datetime, hour.temperature, hour.condition)
54
+ ```
55
+
56
+ ## Exceptions
57
+
58
+ If the API request fails, one of these exceptions (all importable from `pyVisualCrossing`) is raised:
59
+
60
+ | Exception | Description |
61
+ | --------- | ----------- |
62
+ | `VisualCrossingBadRequest` | The request was invalid (invalid dates, bad location parameter, etc.) |
63
+ | `VisualCrossingUnauthorized` | The API key is incorrect, or the account is inactive or disabled |
64
+ | `VisualCrossingTooManyRequests` | Too many daily requests for the current plan |
65
+ | `VisualCrossingInternalServerError` | Visual Crossing's servers encountered an unexpected error |
66
+ | `VisualCrossingException` | Generic base exception for failing to access the API |
67
+
68
+ ## Data
69
+
70
+ ### Current Conditions (`ForecastData`)
71
+
72
+ | Property | Description |
73
+ | -------- | ----------- |
74
+ | `datetime` | Valid time (UTC) |
75
+ | `temperature` | Air temperature |
76
+ | `apparent_temperature` | Feels-like temperature |
77
+ | `dew_point` | Dew point |
78
+ | `condition` | Weather condition text |
79
+ | `icon` | Weather condition icon id |
80
+ | `cloud_cover` | Cloud coverage (%) |
81
+ | `humidity` | Humidity (%) |
82
+ | `precipitation` | Precipitation |
83
+ | `precipitation_probability` | Probability of precipitation (%) |
84
+ | `pressure` | Sea level pressure |
85
+ | `solarradiation` | Solar radiation (W/m2) |
86
+ | `visibility` | Visibility |
87
+ | `uv_index` | UV index |
88
+ | `wind_bearing` | Wind bearing (degrees) |
89
+ | `wind_speed` | Wind speed |
90
+ | `wind_gust_speed` | Wind gust speed |
91
+ | `location_name` | Name of the location |
92
+ | `description` | Weather description |
93
+ | `snow` | Snowfall |
94
+ | `snow_depth` | Snow depth |
95
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
96
+ | `solarenergy` | Solar energy (MJ/m2) |
97
+ | `sunrise` | Sunrise time |
98
+ | `sunset` | Sunset time |
99
+ | `moon_phase` | Moon phase, as a fraction between 0 and 1 |
100
+ | `update_time` | Timestamp of when the data was fetched |
101
+ | `forecast_daily` | List of `ForecastDailyData` |
102
+ | `forecast_hourly` | List of `ForecastHourlyData` |
103
+
104
+ ### Daily Forecast (`ForecastDailyData`)
105
+
106
+ | Property | Description |
107
+ | -------- | ----------- |
108
+ | `datetime` | Valid date (UTC) |
109
+ | `temperature` | Max air temperature for the day |
110
+ | `temp_low` | Min air temperature for the day |
111
+ | `apparent_temperature` | Feels-like temperature |
112
+ | `condition` | Weather condition text |
113
+ | `icon` | Weather condition icon id |
114
+ | `cloud_cover` | Cloud coverage (%) |
115
+ | `dew_point` | Dew point |
116
+ | `humidity` | Humidity (%) |
117
+ | `precipitation` | Precipitation |
118
+ | `precipitation_probability` | Probability of precipitation (%) |
119
+ | `pressure` | Sea level pressure |
120
+ | `uv_index` | UV index |
121
+ | `wind_bearing` | Wind bearing (degrees) |
122
+ | `wind_speed` | Wind speed |
123
+ | `wind_gust` | Wind gust speed |
124
+ | `snow` | Snowfall |
125
+ | `snow_depth` | Snow depth |
126
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
127
+ | `precipitation_cover` | Percentage of the day with precipitation (%) |
128
+ | `solarradiation` | Solar radiation (W/m2) |
129
+ | `solarenergy` | Solar energy (MJ/m2) |
130
+ | `severe_risk` | Risk score of severe weather |
131
+ | `sunrise` | Sunrise time |
132
+ | `sunset` | Sunset time |
133
+ | `moon_phase` | Moon phase, as a fraction between 0 and 1 |
134
+
135
+ ### Hourly Forecast (`ForecastHourlyData`)
136
+
137
+ Only hours later than the current time are included.
138
+
139
+ | Property | Description |
140
+ | -------- | ----------- |
141
+ | `datetime` | Valid date and time (UTC) |
142
+ | `temperature` | Air temperature |
143
+ | `apparent_temperature` | Feels-like temperature |
144
+ | `condition` | Weather condition text |
145
+ | `icon` | Weather condition icon id |
146
+ | `cloud_cover` | Cloud coverage (%) |
147
+ | `dew_point` | Dew point |
148
+ | `humidity` | Humidity (%) |
149
+ | `precipitation` | Precipitation |
150
+ | `precipitation_probability` | Probability of precipitation (%) |
151
+ | `pressure` | Sea level pressure |
152
+ | `uv_index` | UV index |
153
+ | `wind_bearing` | Wind bearing (degrees) |
154
+ | `wind_speed` | Wind speed |
155
+ | `wind_gust_speed` | Wind gust speed |
156
+ | `snow` | Snowfall |
157
+ | `snow_depth` | Snow depth |
158
+ | `precipitation_type` | Type(s) of precipitation, if any (e.g. `rain`, `snow`) |
159
+ | `solarradiation` | Solar radiation (W/m2) |
160
+ | `solarenergy` | Solar energy (MJ/m2) |
161
+ | `severe_risk` | Risk score of severe weather |
162
+ | `visibility` | Visibility |
163
+
164
+ ## Languages
165
+ Available languages include: **ar** (Arabic), **bg** (Bulgiarian), **cs** (Czech), **da** (Danish), **de** (German), **el** (Greek Modern), **en** (English), **es** (Spanish), **fa** (Farsi), **fi** (Finnish), **fr** (French), **he** (Hebrew), **hu**, (Hungarian), **it** (Italian), **ja** (Japanese), **ko** (Korean), **nl** (Dutch), **pl** (Polish), **pt** (Portuguese), **sr** (Serbian), **sv** (Swedish), **tr** (Turkish), **uk** (Ukranian), **vi** (Vietnamese) and **zh** (Chinese).
166
+
167
+ ## Metrics
168
+ All records are returned using the *Metric* unit system. There is no conversion possible at the moment.
169
+
170
+ | Weather variable | Measurement Unit |
171
+ | ----------------------------------- | ------------------------ |
172
+ | Datetime | UTC datetime |
173
+ | Temperature, Heat Index & Wind Chill | Degrees Celcius |
174
+ | Precipitation | Millimeters |
175
+ | snow | Centimeters |
176
+ | Wind & Wind Gust | Kilometers Per Hour |
177
+ | Visibility | Kilometers |
178
+ | Pressure | Millibars (Hectopascals) |
179
+ | Solar Radiation | W/m2 |
180
+ | Solar Energy | MJ/m2 |
181
+
182
+ ## Icons
183
+ We use the Iconset *icons2*, which gives a more detailed description of the conditions.
184
+
185
+ | Icon id | Weather Conditions |
186
+ | -------------------- | ---------------------------- |
187
+ | snow | Amount of snow is greater than zero |
188
+ | snow-showers-day | Periods of snow during the day |
189
+ | snow-showers-night | Periods of snow during the night |
190
+ | thunder-rain | Thunderstorms throughout the day or night |
191
+ | thunder-showers-day | Possible thunderstorms throughout the day |
192
+ | thunder-showers-night | Possible thunderstorms throughout the night |
193
+ | rain | Amount of rainfall is greater than zero |
194
+ | showers-day | Rain showers during the day |
195
+ | showers-night | Rain showers during the night |
196
+ | fog | Visibility is low (lower than one kilometer or mile) |
197
+ | wind | Wind speed is high (greater than 30 kph or mph) |
198
+ | cloudy | Cloud cover is greater than 90% cover |
199
+ | partly-cloudy-day | Cloud cover is greater than 20% cover during day time. |
200
+ | partly-cloudy-night | Cloud cover is greater than 20% cover during night time. |
201
+ | clear-day | Cloud cover is less than 20% cover during day time |
202
+ | clear-night | Cloud cover is less than 20% cover during night time |
@@ -1,4 +1,5 @@
1
1
  """Python Wrapper for Visual Crossing Weather API."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  from pyVisualCrossing.api import (
@@ -17,6 +18,19 @@ from pyVisualCrossing.data import (
17
18
  from pyVisualCrossing.const import SUPPORTED_LANGUAGES
18
19
 
19
20
  __title__ = "pyVisualCrossing"
20
- __version__ = "0.1.16"
21
+ __version__ = "1.0.1"
21
22
  __author__ = "briis"
22
23
  __license__ = "MIT"
24
+
25
+ __all__ = [
26
+ "VisualCrossing",
27
+ "VisualCrossingBadRequest",
28
+ "VisualCrossingException",
29
+ "VisualCrossingInternalServerError",
30
+ "VisualCrossingUnauthorized",
31
+ "VisualCrossingTooManyRequests",
32
+ "ForecastData",
33
+ "ForecastDailyData",
34
+ "ForecastHourlyData",
35
+ "SUPPORTED_LANGUAGES",
36
+ ]