Skip to content

Instantly share code, notes, and snippets.

@john-walter-munene
Created April 9, 2025 16:20
Show Gist options
  • Save john-walter-munene/cfc269e15c5a5a89aeecd04c0e9e6a56 to your computer and use it in GitHub Desktop.
Save john-walter-munene/cfc269e15c5a5a89aeecd04c0e9e6a56 to your computer and use it in GitHub Desktop.
openapi: 3.1.0
x-stoplight:
id: sjhwknh580eif
info:
title: ' OpenWeatherMap API'
version: '2.5'
summary: Get the current weather
description: 'Get the current weather, dialy 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 5 days for your reference. Interactive maps show precipitation, clouds, pressure, wind around your location stations. Data avaialble in JSON, XML, or HTML format. **Note**: Thie 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 (using the `id` parameter) will provide the most precise location results. '
contact:
name: Support
url: 'https://openweathermap.org/api'
email: [email protected]
termsOfService: 'https://openweathermap.org/terms'
license:
name: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
url: 'https://creativecommons.org/licenses/by-sa/4.0/'
servers:
- url: 'https://api.openweathermap.org/data/2.5'
description: prod
paths:
/weather:
get:
summary: weather
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
x-examples:
Example 1:
coord:
lon: -121.95
lat: 37.35
weather:
- id: 803
main: Clouds
description: broken clouds
icon: 04n
base: stations
main:
temp: 45.25
feels_like: 41.16
temp_min: 41
temp_max: 50
pressure: 1026
humidity: 75
visibility: 16093
wind:
speed: 2.57
deg: 36
clouds:
all: 75
dt: 1579415808
sys:
type: 1
id: 5845
country: US
sunrise: 1579360793
sunset: 1579396557
timezone: -28800
id: 0
name: Santa Clara
cod: 200
properties:
coord:
type: object
properties:
lon:
type: number
description: "- description: City geo location, longitude\r\n- example: 145.77"
lat:
type: number
description: "- description: City geo location, latitude\r\n- example: -16.92"
weather:
type: array
items:
type: object
properties:
id:
type: integer
description: "- description: Weather condition id\r\n- example: ‘803’"
main:
type: string
description: "- description: Group of weather parameters (Rain, Snow, Extreme etc.)\r\n- example: clouds"
description:
type: string
description: "- description: Weather condition within the group\r\n- example: broken clouds"
icon:
type: string
description: "- description: Weather icon id\r\n- example: 04n"
base:
type: string
description: "- description: Internal parameter\r\n- example: cmc stations"
main:
type: object
properties:
temp:
type: number
description: "- description: ‘Temperature. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.’\r\n- example: 293.25"
feels_like:
type: number
description: "- description: What the weather feels like despite the actual numbers\r\n- example: 41.16"
temp_min:
type: integer
description: "- 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.’\r\n- example: 289.82"
temp_max:
type: integer
description: "- 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.’\r\n- example: 295.37"
pressure:
type: integer
description: "- description: ‘Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa’\r\n- example: 1019"
humidity:
type: integer
description: "- description: ‘Humidity, %’\r\n- example: 83"
visibility:
type: integer
description: "- description: ‘Visibility, meter’\r\n- example: 16093"
wind:
type: object
properties:
speed:
type: number
description: "- description: ‘Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.’\r\n- example: 5.1"
deg:
type: integer
description: "- description: ‘’\r\n- example: 150"
clouds:
type: object
description: "- description: ‘Cloudiness, %’\r\n- example: 75"
properties:
all:
type: integer
dt:
type: integer
description: "- description: ‘Time of data calculation, unix, UTC’\r\n- example: 1435658272"
sys:
type: object
properties:
type:
type: integer
description: "- description: Internal parameter\r\n- example: 1"
id:
type: integer
description: "- description: Internal parameter\r\n- example: 8166"
country:
type: string
description: "- description: ‘Country code (GB, JP etc.)’\r\n- example: AU"
sunrise:
type: integer
description: "- description: ‘Sunrise time, unix, UTC’\r\n- example: 1435610796"
sunset:
type: integer
description: "- description: ‘Sunset time, unix, UTC’\r\n- example: 1435650870"
timezone:
type: integer
description: "- description: the timezone for the station\r\n- example: -28800"
id:
type: integer
description: "- description: City ID\r\n- example: 2172797"
name:
type: string
cod:
type: integer
description: "- description: Name\r\n- example: Cairns"
operationId: get-weather
x-stoplight:
id: plbsytqjom21j
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.'
parameters:
- schema:
type: string
in: query
name: zip
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.'
- schema:
type: string
enum:
- standard
- metric
- imperial
in: query
name: units
description: '**Units**. *Example: imperial*. Possible values: `standard`, `metric`, and `imperial`. When you do not use the `units` parameter, the format is `standard` by default.'
- schema:
type: string
in: query
name: q
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.'
- schema:
type: string
in: query
name: id
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 3 city IDs, it’s treated as 3 API calls.*'
- $ref: '#/components/parameters/lon'
- schema:
type: string
in: query
name: lat
description: '**Latitude**. *Example: 35*. Latitude coordinate of the location of your interest. Must use with `lat`.'
- schema:
type: string
default: en
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
in: query
name: lang
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`.'
- schema:
type: string
default: json
enum:
- json
- xml
- html
in: query
name: mode
description: '**Mode**. Example: html. Determines the format of the response. Possible values are `json`, `xml`, and `html`. If the mode parameter is empty, the format is `json` by default.'
tags:
- weather endpoints
components:
schemas:
User:
title: User
type: object
description: ''
examples:
- id: 142
firstName: Alice
lastName: Smith
email: [email protected]
dateOfBirth: '1997-10-31'
emailVerified: true
signUpDate: '2019-08-24'
properties:
id:
type: integer
description: Unique identifier for the given user.
x-stoplight:
id: pgvfulsp6rz7h
firstName:
type: string
x-stoplight:
id: kqneub5pg1bnk
lastName:
type: string
x-stoplight:
id: ad1k0vrgl4mmd
email:
type: string
format: email
x-stoplight:
id: k10gbdx42ctwh
dateOfBirth:
type: string
format: date
example: '1997-10-31'
x-stoplight:
id: au8dx0y08g2me
emailVerified:
type: boolean
description: Set to true if the user's email has been verified.
x-stoplight:
id: 9ofq4qhvm9uk1
createDate:
type: string
format: date
description: The date that the user was created.
x-stoplight:
id: ibier1yd7d4fq
required:
- id
- firstName
- lastName
- email
- emailVerified
x-stoplight:
id: sdql2ny019e4l
securitySchemes:
app_id:
name: appid
type: apiKey
in: query
parameters:
lon:
name: lon
in: query
required: false
schema:
type: string
description: '**Longitude**. *Example: 139*. Longitude coordinate of the location of your interest. Must use with `lat`.'
x-internal: false
security:
- app_id: []
tags:
- name: weather endpoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment