· 6 years ago · Dec 15, 2019, 11:10 AM
1openapi: "3.0.2"
2
3info:
4 title: "OpenWeatherMap API"
5 description: "Get the current weather, daily forecast for 16 days, and a three-hour-interval forecast for 5 days for your city. Helpful stats, graphics, and this day in history charts are available for your reference. Interactive maps show precipitation, clouds, pressure, wind around your location stations. Data is available in JSON, XML, or HTML format. **Note**: This sample Swagger file covers the `current` endpoint only from the OpenWeatherMap API. <br/><br/> **Note**: All parameters are optional, but you must select at least one parameter. Calling the API by city ID (using the `id` parameter) will provide the most precise location results."
6 version: "2.5"
7 termsOfService: "https://openweathermap.org/terms"
8 contact:
9 name: "OpenWeatherMap API"
10 url: "https://openweathermap.org/api"
11 email: "some_email@gmail.com"
12 license:
13 name: "CC Attribution-ShareAlike 4.0 (CC BY-SA 4.0)"
14 url: "https://openweathermap.org/price"
15
16servers:
17- url: "https://api.openweathermap.org/data/2.5"
18
19paths:
20 /weather:
21 get:
22 tags:
23 - Current Weather Data
24 summary: "Call current weather data for one location"
25 description: "Access current weather data for any location on Earth including over 200,000 cities! Current weather is frequently updated based on global models and data from more than 40,000 weather stations."
26 operationId: CurrentWeatherData
27 parameters:
28 - $ref: '#/components/parameters/q'
29 - $ref: '#/components/parameters/id'
30 - $ref: '#/components/parameters/lat'
31 - $ref: '#/components/parameters/lon'
32 - $ref: '#/components/parameters/zip'
33 - $ref: '#/components/parameters/units'
34 - $ref: '#/components/parameters/lang'
35 - $ref: '#/components/parameters/mode'
36
37 responses:
38 200:
39 description: Successful response
40 content:
41 application/json:
42 schema:
43 $ref: '#/components/schemas/200'
44 404:
45 description: Not found response
46 content:
47 text/plain:
48 schema:
49 title: Weather not found
50 type: string
51 example: Not found
52security:
53- app_id: []
54
55tags:
56 - name: Current Weather Data
57 description: "Get current weather details"
58
59externalDocs:
60 description: API Documentation
61 url: https://openweathermap.org/api
62
63components:
64
65 parameters:
66 q:
67 name: q
68 in: query
69 description: "**City name**. *Example: London*. You can call by city name, or by city name and country code. The API responds with a list of results that match a searching word. For the query value, type the city name and optionally the country code divided by a comma; use ISO 3166 country codes."
70 schema:
71 type: string
72 id:
73 name: id
74 in: query
75 description: "**City ID**. *Example: `2172797`*. You can call by city ID. The API responds with the exact result. The List of city IDs can be downloaded [here](http://bulk.openweathermap.org/sample/). You can include multiple cities in this parameter — just separate them by commas. The limit of locations is 20. *Note: A single ID counts as a one API call. So, if you have city IDs, it's treated as 3 API calls.*"
76 schema:
77 type: string
78
79 lat:
80 name: lat
81 in: query
82 description: "**Latitude**. *Example: 35*. The latitude coordinate of the location of your interest. Must use with `lon`."
83 schema:
84 type: string
85
86 lon:
87 name: lon
88 in: query
89 description: "**Longitude**. *Example: 139*. Longitude coordinate of the location of your interest. Must use with `lat`."
90 schema:
91 type: string
92
93 zip:
94 name: zip
95 in: query
96 description: "**Zip code**. Search by zip code. *Example: 95050,us*. Please note that if the country is not specified, the search uses USA as a default."
97 schema:
98 type: string
99
100 units:
101 name: units
102 in: query
103 description: '**Units**. *Example: imperial*. Possible values: `standard`, `metric`, and `imperial`. When you do not use the `units` parameter, the format is `standard` by default.'
104 schema:
105 type: string
106 enum: [standard, metric, imperial]
107 default: "imperial"
108
109 lang:
110 name: lang
111 in: query
112 description: '**Language**. *Example: en*. You can use lang parameter to get the output in your language. We support the following languages that you can use with the corresponded lang values: Arabic - `ar`, Bulgarian - `bg`, Catalan - `ca`, Czech - `cz`, German - `de`, Greek - `el`, English - `en`, Persian (Farsi) - `fa`, Finnish - `fi`, French - `fr`, Galician - `gl`, Croatian - `hr`, Hungarian - `hu`, Italian - `it`, Japanese - `ja`, Korean - `kr`, Latvian - `la`, Lithuanian - `lt`, Macedonian - `mk`, Dutch - `nl`, Polish - `pl`, Portuguese - `pt`, Romanian - `ro`, Russian - `ru`, Swedish - `se`, Slovak - `sk`, Slovenian - `sl`, Spanish - `es`, Turkish - `tr`, Ukrainian - `ua`, Vietnamese - `vi`, Chinese Simplified - `zh_cn`, Chinese Traditional - `zh_tw`.'
113 schema:
114 type: string
115 enum: [ar, bg, ca, cz, de, el, en, fa, fi, fr, gl, hr, hu, it, ja, kr, la, lt, mk, nl, pl, pt, ro, ru, se, sk, sl, es, tr, ua, vi, zh_cn, zh_tw]
116 default: "en"
117
118 mode:
119 name: mode
120 in: query
121 description: "**Mode**. *Example: html*. Determines the format of the response. Possible values are `xml` and `html`. If the mode parameter is empty, the format is `json` by default."
122 schema:
123 type: string
124 enum: [json, xml, html]
125 default: "json"
126
127 schemas:
128 200:
129 title: Successful response
130 type: object
131 properties:
132 coord:
133 $ref: '#/components/schemas/Coord'
134 weather:
135 type: array
136 items:
137 $ref: '#/components/schemas/Weather'
138 description: (more info Weather condition codes)
139 base:
140 type: string
141 description: Internal parameter
142 example: cmc stations
143 main:
144 $ref: '#/components/schemas/Main'
145 visibility:
146 type: integer
147 description: Visibility, meter
148 example: 16093
149 wind:
150 $ref: '#/components/schemas/Wind'
151 clouds:
152 $ref: '#/components/schemas/Clouds'
153 rain:
154 $ref: '#/components/schemas/Rain'
155 snow:
156 $ref: '#/components/schemas/Snow'
157 dt:
158 type: integer
159 description: Time of data calculation, unix, UTC
160 format: int32
161 example: 1435658272
162 sys:
163 $ref: '#/components/schemas/Sys'
164 id:
165 type: integer
166 description: City ID
167 format: int32
168 example: 2172797
169 name:
170 type: string
171 example: Cairns
172 cod:
173 type: integer
174 description: Internal parameter
175 format: int32
176 example: 200
177 Coord:
178 title: Coord
179 type: object
180 properties:
181 lon:
182 type: number
183 description: City geo location, longitude
184 example: 145.77000000000001
185 lat:
186 type: number
187 description: City geo location, latitude
188 example: -16.920000000000002
189 Weather:
190 title: Weather
191 type: object
192 properties:
193 id:
194 type: integer
195 description: Weather condition id
196 format: int32
197 example: 803
198 main:
199 type: string
200 description: Group of weather parameters (Rain, Snow, Extreme etc.)
201 example: Clouds
202 description:
203 type: string
204 description: Weather condition within the group
205 example: broken clouds
206 icon:
207 type: string
208 description: Weather icon id
209 example: 04n
210 Main:
211 title: Main
212 type: object
213 properties:
214 temp:
215 type: number
216 description: 'Temperature. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.'
217 example: 293.25
218 pressure:
219 type: integer
220 description: Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa
221 format: int32
222 example: 1019
223 humidity:
224 type: integer
225 description: Humidity, %
226 format: int32
227 example: 83
228 temp_min:
229 type: number
230 description: 'Minimum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.'
231 example: 289.81999999999999
232 temp_max:
233 type: number
234 description: 'Maximum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.'
235 example: 295.37
236 sea_level:
237 type: number
238 description: Atmospheric pressure on the sea level, hPa
239 example: 984
240 grnd_level:
241 type: number
242 description: Atmospheric pressure on the ground level, hPa
243 example: 990
244 Wind:
245 title: Wind
246 type: object
247 properties:
248 speed:
249 type: number
250 description: 'Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.'
251 example: 5.0999999999999996
252 deg:
253 type: integer
254 description: Wind direction, degrees (meteorological)
255 format: int32
256 example: 150
257 Clouds:
258 title: Clouds
259 type: object
260 properties:
261 all:
262 type: integer
263 description: Cloudiness, %
264 format: int32
265 example: 75
266 Rain:
267 title: Rain
268 type: object
269 properties:
270 3h:
271 type: integer
272 description: Rain volume for the last 3 hours
273 format: int32
274 example: 3
275 Snow:
276 title: Snow
277 type: object
278 properties:
279 3h:
280 type: number
281 description: Snow volume for the last 3 hours
282 example: 6
283 Sys:
284 title: Sys
285 type: object
286 properties:
287 type:
288 type: integer
289 description: Internal parameter
290 format: int32
291 example: 1
292 id:
293 type: integer
294 description: Internal parameter
295 format: int32
296 example: 8166
297 message:
298 type: number
299 description: Internal parameter
300 example: 0.0166
301 country:
302 type: string
303 description: Country code (GB, JP etc.)
304 example: AU
305 sunrise:
306 type: integer
307 description: Sunrise time, unix, UTC
308 format: int32
309 example: 1435610796
310 sunset:
311 type: integer
312 description: Sunset time, unix, UTC
313 format: int32
314 example: 1435650870
315
316 securitySchemes:
317 app_id:
318 type: apiKey
319 description: API key to authorize requests. If you don't have an OpenWeatherMap API key, use `fd4698c940c6d1da602a70ac34f0b147`.
320 name: appid
321 in: query