synoptic.services.SynopticAPI#

class synoptic.services.SynopticAPI(service, *, token=None, verbose=True, **params)[source]#

Request data from Synoptic’s Weather API.

This is the parent class for all other services.

Parameters:
  • service ({'timeseries', 'latest', 'nearesttime', 'precipitation', ...}) – The Synoptic API service to request data from. Refer to the Synoptic Weather Data API documentation for a full list of services: https://docs.synopticdata.com/services/weather-data-api

  • token (str) –

    A 32-character Synoptic account token. If None, attempts to retrieve the token from the following sources (in order):

    1. Environment variable SYNOPTIC_TOKEN,

    2. The token="..." value in ~/.config/SynopticPy/config.toml.

  • verbose (bool) – If True, prints each step of the request process.

  • **params (dict, optional) –

    Additional Synoptic API request parameters. Refer to the Synoptic Weather Data API documentation for expected and valid arguments for each service: https://docs.synopticdata.com/services/weather-data-api

    This class accepts the following extended input:

    • Where Synoptic expects comma-separated strings, you can instead provided a list or tuple (e.g., stid=['wbb', 'ukbkb'], radius=('wbb', 20)).

    • Datetime parameters like start and end can be a datetime.datetime or a string in the format YYYY-MM-DD HH:MM.

    • Duration parameters like recent can be a datetime.timedelta or a duration string (e.g., '1d12h', 30m).

    • Parameters that accept 0, 1, on, off can be given as boolean values.

__init__(service, *, token=None, verbose=True, **params)[source]#
Parameters:
  • service (Literal['timeseries', 'latest', 'nearesttime', 'precipitation', 'qcsegments', 'latency', 'metadata', 'qctypes', 'variables', 'networks', 'networktypes'])

  • token (str | Token | None)

Methods

__init__(service, *[, token, verbose])