{"id":20687286,"url":"https://github.com/lukaskubis/darkskylib","last_synced_at":"2025-05-07T15:47:57.294Z","repository":{"id":62566474,"uuid":"67506799","full_name":"lukaskubis/darkskylib","owner":"lukaskubis","description":"Python wrapper for the Dark Sky API","archived":false,"fork":false,"pushed_at":"2020-01-23T20:57:38.000Z","size":47,"stargazers_count":113,"open_issues_count":7,"forks_count":23,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-19T12:08:50.914Z","etag":null,"topics":["dark-sky","forecast","python","weather"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/darkskylib/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukaskubis.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-06T12:37:55.000Z","updated_at":"2024-07-22T19:52:32.000Z","dependencies_parsed_at":"2022-11-03T16:30:21.849Z","dependency_job_id":null,"html_url":"https://github.com/lukaskubis/darkskylib","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukaskubis%2Fdarkskylib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukaskubis%2Fdarkskylib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukaskubis%2Fdarkskylib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukaskubis%2Fdarkskylib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukaskubis","download_url":"https://codeload.github.com/lukaskubis/darkskylib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231449738,"owners_count":18378431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dark-sky","forecast","python","weather"],"created_at":"2024-11-16T22:56:41.879Z","updated_at":"2024-12-27T07:09:06.396Z","avatar_url":"https://github.com/lukaskubis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"darkskylib\n==========\n\nThis  library for the `Dark Sky\nAPI \u003chttps://darksky.net/dev/docs\u003e`__ provides access to detailed\nweather information from around the globe.\n\nQuick start\n-----------\n\nBefore you start using this library, you need to get your API key\n`here \u003chttps://darksky.net/dev/register\u003e`__.\n\n\nAPI Calls\n~~~~~~~~~\n\nFunction ``forecast`` handles all request parameters and returns a\n``Forecast`` object.\n\n.. code:: python\n\n    \u003e\u003e\u003e from darksky import forecast\n    \u003e\u003e\u003e boston = forecast(key, 42.3601, -71.0589)\n    \u003e\u003e\u003e\n\nThe first 3 positional arguments are identical to the 3 required\nparameters for API call. The optional query parameters need to be\nprovided as keyword arguments.\n\nUsing ``time`` argument will get you a **time machine call**.\nUsing ``timeout`` argument will set default `request timeout \u003chttp://docs.python-requests.org/en/master/api/#requests.request\u003e`__ .\n\n.. code:: python\n\n    \u003e\u003e\u003e BOSTON = key, 42.3601, -71.0589\n    \u003e\u003e\u003e from datetime import datetime as dt\n    \u003e\u003e\u003e t = dt(2013, 5, 6, 12).isoformat()\n    \u003e\u003e\u003e boston = forecast(*BOSTON, time=t)\n    \u003e\u003e\u003e boston.time\n    1367866800\n\nData Points and Data Blocks\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe values as well as ``DataPoint`` and ``DataBlock`` objects are\naccessed using instance attributes or dictionary keys. You can access\ncurrent values directly, without going through ``currently`` data point.\n\n.. code:: python\n\n    \u003e\u003e\u003e boston['currently']['temperature']\n    60.72\n    \u003e\u003e\u003e boston.temperature\n    60.72\n\n**Data blocks** are indexable and iterable by their ``data`` values.\n\n.. code:: python\n\n    \u003e\u003e\u003e len(boston.hourly)\n    24\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e boston.hourly[1].temperature\n    59.49\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # list temperatures for next 10 hours\n    ... [hour.temperature for hour in boston.hourly[:10]]\n    [60.83, 59.49, 58.93, 57.95, 56.01, 53.95, 51.21, 49.21, 47.95, 46.31]\n\nNonexistent attributes will raise ``AttributeError`` and dictionary keys\n``KeyError`` the way you'd expect.\n\nRaw data\n~~~~~~~~\n\nTo get the raw data dictionary, you can either access it through\ninstance attributes or navigate to it through dictionary keys, the same\nway you would navigate the actual dictionary.\n\n.. code:: python\n\n    \u003e\u003e\u003e boston.hourly[2]\n    {'ozone': 290.06, 'temperature': 58.93, 'pressure': 1017.8, 'windBearing': 274, 'dewPoint': 52.58, 'cloudCover': 0.29, 'apparentTemperature': 58.93, 'windSpeed': 7.96, 'summary': 'Partly Cloudy', 'icon': 'partly-cloudy-night', 'humidity': 0.79, 'precipProbability': 0, 'precipIntensity': 0, 'visibility': 8.67, 'time': 1476410400}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e boston['hourly']['data'][2]\n    {'ozone': 290.06, 'temperature': 58.93, 'pressure': 1017.8, 'windBearing': 274, 'dewPoint': 52.58, 'cloudCover': 0.29, 'apparentTemperature': 58.93, 'windSpeed': 7.96, 'summary': 'Partly Cloudy', 'icon': 'partly-cloudy-night', 'humidity': 0.79, 'precipProbability': 0, 'precipIntensity': 0, 'visibility': 8.67, 'time': 1476410400}\n\nFlags and Alerts\n~~~~~~~~~~~~~~~~\n\nAll dashes ``-`` in attribute names of **Flags** objects are replaced by\nunderscores ``_``. This doesn't affect the dictionary keys.\n\n.. code:: python\n\n    \u003e\u003e\u003e # instead of 'boston.flags.isd-stations'\n    ... boston.flags.isd_stations\n    ['383340-99999', '383390-99999', '383410-99999', '384620-99999', '384710-99999']\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e boston.flags['isd-stations']\n    ['383340-99999', '383390-99999', '383410-99999', '384620-99999', '384710-99999']\n\nEven though **Alerts** are represented by a list, the data accessibility\nthrough instance attributes is preserved for alerts in the list.\n\n.. code:: python\n\n    \u003e\u003e\u003e boston.alerts[0].title\n    'Freeze Watch for Norfolk, MA'\n\nUpdating data\n~~~~~~~~~~~~~\n\nUse ``refresh()`` method to update data of a ``Forecast`` object. The\n``refresh()`` method takes optional queries (including ``time``, making\nit a **Time machine** object) as keyword arguments. Calling\n``refresh()`` without any arguments will set all queries to default\nvalues. Use ``timeout`` argument to set the request timeout.\n\n.. code:: python\n\n    \u003e\u003e\u003e boston.refresh()\n    \u003e\u003e\u003e (boston.time, boston.temperature, len(boston.hourly))\n    (1476403500, 60.72, 49)\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e boston.refresh(units='si', extend='hourly')\n    \u003e\u003e\u003e (boston.time, boston.temperature, len(boston.hourly))\n    (1476404205, 15.81, 169)\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e boston.refresh(units='us')\n    \u003e\u003e\u003e (boston.time, boston.temperature, len(boston.hourly))\n    (1476404489, 60.57, 49)\n\nFor Developers\n~~~~~~~~~~~~~~\n\nResponse headers are stored in a dictionary under ``response_headers``\nattribute.\n\n.. code:: python\n\n    \u003e\u003e\u003e boston.response_headers['X-response-Time']\n    '146.035ms'\n\nExample script\n--------------\n\n.. code:: python\n\n    from darksky import forecast\n    from datetime import date, timedelta\n\n    BOSTON = 42.3601, 71.0589\n\n    weekday = date.today()\n    with forecast('API_KEY', *BOSTON) as boston:\n        print(boston.daily.summary, end='\\n---\\n')\n        for day in boston.daily:\n            day = dict(day = date.strftime(weekday, '%a'),\n                       sum = day.summary,\n                       tempMin = day.temperatureMin,\n                       tempMax = day.temperatureMax\n                       )\n            print('{day}: {sum} Temp range: {tempMin} - {tempMax}'.format(**day))\n            weekday += timedelta(days=1)\n\nOutput:\n\n::\n\n    Light rain on Friday and Saturday, with temperatures bottoming out at 48°F on Tuesday.\n    ---\n    Sun: Partly cloudy in the morning. Temp range: 44.86 - 57.26°F\n    Mon: Mostly cloudy in the morning. Temp range: 44.26 - 55.28°F\n    Tue: Clear throughout the day. Temp range: 36.85 - 47.9°F\n    Wed: Partly cloudy starting in the afternoon, continuing until evening. Temp range: 33.23 - 47.93°F\n    Thu: Light rain overnight. Temp range: 35.75 - 49.71°F\n    Fri: Light rain in the morning and afternoon. Temp range: 45.47 - 57.11°F\n    Sat: Drizzle in the morning. Temp range: 43.3 - 62.08°F\n    Sun: Clear throughout the day. Temp range: 39.81 - 60.84°F\n\nLicense\n-------\n\nThe code is available under terms of `MIT\nLicense \u003chttps://raw.githubusercontent.com/lukaskubis/darkskylib/master/LICENSE\u003e`__\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukaskubis%2Fdarkskylib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukaskubis%2Fdarkskylib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukaskubis%2Fdarkskylib/lists"}