Skip to content

amos_client

Client for KMA Aviation Meteorology AMOS API.

AMOS (Aerodrome Meteorological Observation Station) provides weather observations from airports and aerodromes for aviation safety.

AMOSClient

Client for accessing KMA Aviation Meteorology AMOS data.

Provides access to: - Airport weather observations - Aerodrome meteorological data - Aviation-specific weather parameters

Source code in python/src/kma_mcp/aviation/amos_client.py
class AMOSClient:
    """Client for accessing KMA Aviation Meteorology AMOS data.

    Provides access to:
    - Airport weather observations
    - Aerodrome meteorological data
    - Aviation-specific weather parameters
    """

    BASE_URL = 'https://apihub.kma.go.kr/api/typ01/url'

    def __init__(self, auth_key: str, timeout: float = 30.0):
        """Initialize AMOS client.

        Args:
            auth_key: KMA API authentication key
            timeout: Request timeout in seconds (default: 30.0)
        """
        self.auth_key = auth_key
        self._client = httpx.Client(timeout=timeout)

    def __enter__(self) -> 'AMOSClient':
        """Context manager entry."""
        return self

    def __exit__(self, *args: object) -> None:
        """Context manager exit."""
        self.close()

    def close(self) -> None:
        """Close the HTTP client."""
        self._client.close()

    def _make_request(self, endpoint: str, params: dict[str, Any]) -> dict[str, Any]:
        """Make an API request."""
        params['authKey'] = self.auth_key
        url = f'{self.BASE_URL}/{endpoint}'
        response = self._client.get(url, params=params)
        response.raise_for_status()
        return response.json()

    def get_airport_observations(
        self,
        tm: str,
        dtm: int = 60,
    ) -> dict[str, Any]:
        """Get aerodrome meteorological observations.

        AMOS provides weather observations from airports and aerodromes
        for aviation operations and safety.

        Args:
            tm: Observation time in 'YYYYMMDDHHmm' format
            dtm: Data time range in minutes before tm (default: 60)
                 Typical values: 30, 60, 120, 180

        Returns:
            Airport weather observation data

        Example:
            >>> with AMOSClient('api_key') as client:
            >>>     data = client.get_airport_observations('202501011200', dtm=60)
        """
        params = {'tm': tm, 'dtm': dtm, 'help': '0'}
        return self._make_request('amos.php', params)

    def get_amdar_data(
        self,
        tm1: str,
        tm2: str,
        st: str = 'E',
    ) -> dict[str, Any]:
        """Get AMDAR aircraft meteorological data.

        AMDAR (Aircraft Meteorological Data Relay) provides in-flight
        weather observations from commercial aircraft equipped with
        meteorological sensors.

        Args:
            tm1: Start time in 'YYYYMMDDHHmm' format
            tm2: End time in 'YYYYMMDDHHmm' format
            st: Station type filter (default: 'E')
                Options: 'E' (all), specific station codes

        Returns:
            AMDAR aircraft meteorological data

        Example:
            >>> with AMOSClient('api_key') as client:
            >>>     data = client.get_amdar_data(
            >>>         '202501011200', '202501011400', st='E'
            >>>     )
        """
        params = {'tm1': tm1, 'tm2': tm2, 'st': st, 'help': '0'}
        return self._make_request('amdar_kma.php', params)

close()

Close the HTTP client.

Source code in python/src/kma_mcp/aviation/amos_client.py
def close(self) -> None:
    """Close the HTTP client."""
    self._client.close()

get_airport_observations(tm, dtm=60)

Get aerodrome meteorological observations.

AMOS provides weather observations from airports and aerodromes for aviation operations and safety.

Parameters:

  • tm (str) –

    Observation time in 'YYYYMMDDHHmm' format

  • dtm (int, default: 60 ) –

    Data time range in minutes before tm (default: 60) Typical values: 30, 60, 120, 180

Returns:

  • dict[str, Any]

    Airport weather observation data

Example

with AMOSClient('api_key') as client: data = client.get_airport_observations('202501011200', dtm=60)

Source code in python/src/kma_mcp/aviation/amos_client.py
def get_airport_observations(
    self,
    tm: str,
    dtm: int = 60,
) -> dict[str, Any]:
    """Get aerodrome meteorological observations.

    AMOS provides weather observations from airports and aerodromes
    for aviation operations and safety.

    Args:
        tm: Observation time in 'YYYYMMDDHHmm' format
        dtm: Data time range in minutes before tm (default: 60)
             Typical values: 30, 60, 120, 180

    Returns:
        Airport weather observation data

    Example:
        >>> with AMOSClient('api_key') as client:
        >>>     data = client.get_airport_observations('202501011200', dtm=60)
    """
    params = {'tm': tm, 'dtm': dtm, 'help': '0'}
    return self._make_request('amos.php', params)

get_amdar_data(tm1, tm2, st='E')

Get AMDAR aircraft meteorological data.

AMDAR (Aircraft Meteorological Data Relay) provides in-flight weather observations from commercial aircraft equipped with meteorological sensors.

Parameters:

  • tm1 (str) –

    Start time in 'YYYYMMDDHHmm' format

  • tm2 (str) –

    End time in 'YYYYMMDDHHmm' format

  • st (str, default: 'E' ) –

    Station type filter (default: 'E') Options: 'E' (all), specific station codes

Returns:

  • dict[str, Any]

    AMDAR aircraft meteorological data

Example

with AMOSClient('api_key') as client: data = client.get_amdar_data( '202501011200', '202501011400', st='E' )

Source code in python/src/kma_mcp/aviation/amos_client.py
def get_amdar_data(
    self,
    tm1: str,
    tm2: str,
    st: str = 'E',
) -> dict[str, Any]:
    """Get AMDAR aircraft meteorological data.

    AMDAR (Aircraft Meteorological Data Relay) provides in-flight
    weather observations from commercial aircraft equipped with
    meteorological sensors.

    Args:
        tm1: Start time in 'YYYYMMDDHHmm' format
        tm2: End time in 'YYYYMMDDHHmm' format
        st: Station type filter (default: 'E')
            Options: 'E' (all), specific station codes

    Returns:
        AMDAR aircraft meteorological data

    Example:
        >>> with AMOSClient('api_key') as client:
        >>>     data = client.get_amdar_data(
        >>>         '202501011200', '202501011400', st='E'
        >>>     )
    """
    params = {'tm1': tm1, 'tm2': tm2, 'st': st, 'help': '0'}
    return self._make_request('amdar_kma.php', params)