API Reference

Darksky

class pydarksky.DarkSky(api_key=None)
Parameters:

api_key (str) – Darksky.net API key

Variables:
  • api_key (str) – Darksky.net API key
  • latitude (float) – The requested latitude. Maybe different from the value returned from an API request
  • longitude (float) – The requested longitude. Maybe different from the value returned from an API request
  • or str or int date (datetime) – The requested date/time.
  • extend (bool) –
  • url (str) –
  • api_call_count (int) –
  • response_time (str) – Server response time in ms
  • response_date (str) – Response date and time
  • units (str) – API response units type
  • lang (str) – API call response language
  • excludes (list[str]) – Data blocks to be excluded in API response
  • UNITS (tuple[str]) – Valid Dark Sky API response units
  • LANGS (list[str]) – Valid Dark Sky API response languages
  • EXCLUDES (tuple[str]) – Valid Dark Sky API data block exclusions
exclude_invert()

Inverts the values in self.exclude

>>> import pydarksky
>>> darksky = pydarksky.DarkSky('0' * 32)

>>> darksky.EXCLUDES
('currently', 'minutely', 'hourly', 'daily', 'alerts', 'flags')

>>> darksky.exclude = ["alerts", "flags"]

>>> darksky.exclude
['alerts', 'flags']

>>> darksky.exclude_invert()

>>> darksky.exclude
['currently', 'minutely', 'hourly', 'daily']
url

Build and returns a URL used to make a Dark Sky API call.

weather(latitude=None, longitude=None, date=None)
Parameters:
  • latitude (float) – Locations latitude
  • longitude (float) – Locations longitude
  • or str or int date (datetime) – Date/time for historical weather data
Raises:
  • requests.exceptions.HTTPError – Raises on bad http response
  • TypeError – Raises on invalid param types
Return type:

Weather

Example uses

# DarkSky instantiation
>>> darksky = pydarksky.DarkSky(api_key)

# Pre-define values
>>> darksky.latitude = -34.9285
>>> darksky.longitude = 138.6005
>>> weather = darksky.weather()

# Pass values as params
>>> weather = darksky.weather(latitude=-34.9285, longitude=138.6005)

# Pass values from dict
>>> kwargs = {"longitude": 138.6005, "latitude": -34.9285}
>>> weather = darksky.weather(**kwargs)
weather_last()

Weather data from the last successful weather() call.

Return type:Weather or None

Weather

class pydarksky.Weather(json_raw)

Note

Do not assume the existence of any attribute.

Parameters:

json_raw (str) – JSON string

Variables:
  • json (dict) – [Required] JSON data returned by the Dark Sky API
  • latitude (float) – [Required] The requested latitude. Maybe different from the value passed to DarkSky class.
  • longitude (float) – [Required] The requested longitude. Maybe different from the value passed to DarkSky class.
  • timezone (str) – [Required] The IANA timezone name for the requested location. This is used for text summaries and for determining when hourly and daily data block objects begin.
  • currently (Currently) – A class containing the current weather conditions at the requested location.
  • daily (list[Daily]) – A class containing the current weather conditions at the requested location.
  • daily_summary (str) – A human-readable summary of the daily data block.
  • daily_icon (str) – A machine-readable text summary of the daily data block.
  • hourly (list[Hourly]) – A class containing the current weather conditions day-by-day for the next week.
  • hourly_summary (str) – A human-readable summary of the hourly data block.
  • hourly_icon (str) – A machine-readable text summary of the daily data block.
  • minutely (list[Minutely]) – A class containing the current weather conditions minute-by-minute for the next hour.
  • minutely_summary (str) – A human-readable summary of the minutely data block.
  • minutely_icon (str) – A machine-readable text summary of the daily data block.
  • alerts (list[Alert]) – An alerts array, which, if present, contains any severe weather alerts pertinent to the requested location.

DataBlocks

class pydarksky.Now(data, parent=None)

Note

Do not assume the existence of any attribute.

Variables:
  • apparentTemperature –
  • cloudCover –
  • dewPoint –
  • humidity –
  • icon –
  • nearestStormBearing –
  • nearestStormDistance –
  • ozone –
  • precipIntensity –
  • precipProbability –
  • precipType –
  • pressure –
  • summary –
  • temperature –
  • time –
  • uvIndex –
  • visibility –
  • windBearing –
  • windGust –
  • windSpeed –
class pydarksky.Day(data, parent=None)

Note

Do not assume the existence of any attribute.

Variables:
  • apparentTemperatureHigh –
  • apparentTemperatureHighTime –
  • apparentTemperatureLow –
  • apparentTemperatureLowTime –
  • cloudCover –
  • dewPoint –
  • humidity –
  • icon –
  • moonPhase –
  • ozone –
  • precipAccumulation –
  • precipIntensity –
  • precipIntensityMax –
  • precipIntensityMaxTime –
  • precipProbability –
  • precipType –
  • pressure –
  • summary –
  • sunriseTime –
  • sunsetTime –
  • temperatureHigh –
  • temperatureHighTime –
  • temperatureLow –
  • temperatureLowTime –
  • time –
  • uvIndex –
  • uvIndexTime –
  • visibility –
  • windBearing –
  • windGust –
  • windSpeed –
class pydarksky.Hour(data, parent=None)

Note

Do not assume the existence of any attribute.

Variables:
  • apparentTemperature –
  • cloudCover –
  • dewPoint –
  • humidity –
  • icon –
  • ozone –
  • precipAccumulation –
  • precipIntensity –
  • precipProbability –
  • precipType –
  • pressure –
  • summary –
  • temperature –
  • time –
  • uvIndex –
  • visibility –
  • windBearing –
  • windGust –
  • windSpeed –
class pydarksky.Minute(data, parent=None)

Note

Do not assume the existence of any attribute.

Variables:
  • apparentTemperature –
  • cloudCover –
  • dewPoint –
  • humidity –
  • icon –
  • ozone –
  • precipIntensity –
  • precipProbability –
  • precipType –
  • pressure –
  • summary –
  • time –
  • uvIndex –
  • visibility –
  • windBearing –
  • windGust –
  • windSpeed –

Alerts

class pydarksky.Alert(data, parent=None)
Variables:
  • description (str) – A detailed description of the alert.
  • expires (int) – The UNIX time at which the alert will expire.
  • regions (str) – An array of strings representing the names of the regions covered by this weather alert.
  • severity (str) –

    The severity of the weather alert, will be one of the following values:

    • advisory
    • watch
    • warning
  • time (int) – The UNIX time at which the alert was issued.
  • title (str) – A brief description of the alert.
  • uri (str) – A HTTP(S) URI that one may refer to for detailed information about the alert.

Flags

class pydarksky.Flag(data, parent=None)
Variables:
  • darksky-unavailable – [optional] The presence of this property indicates that the Dark Sky data source supports the given location, but a temporary error (such as a radar station being down for maintenance) has made the data unavailable.
  • sources (list[str]) – This property contains an array of IDs for each data source utilized in servicing this request.
  • units (units) – Indicates the units which were used for the data in this request.

Indices and tables