Weather Stations API

Register and manage personal weather stations and submit measurement data. Aggregated readings are retrievable at minute, hour, and day granularity.

OpenAPI Specification

openweathermap-weather-stations-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: OpenWeatherMap Weather Stations API
  version: 3.0.0
  description: >-
    Register and manage personal weather stations and submit measurement data
    to OpenWeather. Aggregated readings are available for minute, hour, and day
    intervals.
  contact:
    name: OpenWeather
    url: https://openweathermap.org/stations
  license:
    name: Creative Commons Attribution-ShareAlike 4.0 International
    url: https://creativecommons.org/licenses/by-sa/4.0/
servers:
  - url: https://api.openweathermap.org/data/3.0
    description: Weather Stations API base URL
paths:
  /stations:
    get:
      operationId: listStations
      summary: List Registered Weather Stations
      description: Returns the list of all weather stations registered to the API key.
      tags:
        - Stations
      parameters:
        - $ref: '#/components/parameters/Appid'
      responses:
        '200':
          description: Stations list response.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Station'
        '401':
          description: Unauthorized.
        '429':
          description: Too many requests.
    post:
      operationId: createStation
      summary: Register A New Weather Station
      description: Registers a new weather station and returns the assigned station object.
      tags:
        - Stations
      parameters:
        - $ref: '#/components/parameters/Appid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StationInput'
      responses:
        '201':
          description: Station created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Station'
        '400':
          description: Invalid request parameters.
        '401':
          description: Unauthorized.
  /stations/{station_id}:
    get:
      operationId: getStation
      summary: Retrieve A Weather Station
      description: Returns the station object for the supplied identifier.
      tags:
        - Stations
      parameters:
        - name: station_id
          in: path
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/Appid'
      responses:
        '200':
          description: Station response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Station'
    put:
      operationId: updateStation
      summary: Update A Weather Station
      description: Updates the station metadata for the supplied identifier.
      tags:
        - Stations
      parameters:
        - name: station_id
          in: path
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/Appid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StationInput'
      responses:
        '200':
          description: Station updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Station'
    delete:
      operationId: deleteStation
      summary: Delete A Weather Station
      description: Removes the station permanently.
      tags:
        - Stations
      parameters:
        - name: station_id
          in: path
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/Appid'
      responses:
        '204':
          description: Station deleted.
  /measurements:
    get:
      operationId: getMeasurements
      summary: Retrieve Aggregated Measurements
      description: Returns aggregated measurements for a station at minute, hour, or day granularity.
      tags:
        - Measurements
      parameters:
        - name: station_id
          in: query
          required: true
          schema:
            type: string
        - name: type
          in: query
          required: true
          description: Aggregation type. m minute, h hour, d day.
          schema:
            type: string
            enum:
              - m
              - h
              - d
        - name: limit
          in: query
          required: true
          description: Maximum number of records returned.
          schema:
            type: integer
        - name: from
          in: query
          required: false
          schema:
            type: integer
            format: int64
        - name: to
          in: query
          required: false
          schema:
            type: integer
            format: int64
        - $ref: '#/components/parameters/Appid'
      responses:
        '200':
          description: Aggregated measurements response.
    post:
      operationId: postMeasurements
      summary: Submit Station Measurements
      description: Submits one or more measurements collected from a registered station.
      tags:
        - Measurements
      parameters:
        - $ref: '#/components/parameters/Appid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Measurement'
      responses:
        '204':
          description: Measurements accepted.
        '400':
          description: Invalid request parameters.
        '401':
          description: Unauthorized.
components:
  parameters:
    Appid:
      name: appid
      in: query
      required: true
      description: OpenWeather API key.
      schema:
        type: string
  schemas:
    StationInput:
      type: object
      required:
        - external_id
        - name
        - latitude
        - longitude
      properties:
        external_id:
          type: string
        name:
          type: string
        latitude:
          type: number
          format: float
        longitude:
          type: number
          format: float
        altitude:
          type: number
          format: float
    Station:
      allOf:
        - $ref: '#/components/schemas/StationInput'
        - type: object
          properties:
            id:
              type: string
            updated_at:
              type: string
              format: date-time
            created_at:
              type: string
              format: date-time
            rank:
              type: integer
    Measurement:
      type: object
      required:
        - station_id
        - dt
      properties:
        station_id:
          type: string
        dt:
          type: integer
          format: int64
        temperature:
          type: number
          format: float
          description: Air temperature in Celsius.
        wind_speed:
          type: number
          format: float
        wind_gust:
          type: number
          format: float
        pressure:
          type: number
          format: float
          description: Pressure in hectopascals.
        humidity:
          type: number
          format: float
        rain_1h:
          type: number
          format: float
        rain_6h:
          type: number
          format: float
        rain_24h:
          type: number
          format: float
        snow_1h:
          type: number
          format: float
        snow_6h:
          type: number
          format: float
        snow_24h:
          type: number
          format: float
        dew_point:
          type: number
          format: float
        heat_index:
          type: number
          format: float
        humidex:
          type: number
          format: float
        visibility_distance:
          type: number
          format: float
  securitySchemes:
    appid:
      type: apiKey
      in: query
      name: appid
security:
  - appid: []
tags:
  - name: Stations
    description: Register, retrieve, update, and delete personal weather stations.
  - name: Measurements
    description: Submit and retrieve aggregated weather station measurements.