Skip to main content

DarkSky - Async Python 3 Library

Designed with native asyncio support, this libary is better suited to those who need better concurrency support than running requests inside run_in_executor. As this is an asyncio based libary, we do not plan to support Python 2. The minimum Python version needed is 3.5, you can download it here

Usage

You can use several methods to use this libary, including directly calling the helper function forecast. This offers no setup but is significantly slower due to the need to create the client in the background everytime. Its better to just create the client and save it to a variable than using this function.

Client example:

import asyncio
import darksky_async

async def main():
    client = darksky_async.Client("DarkSky key goes here")

    weather = await client.forecast(
        37.8267, # latitude
        -122.4233 # longitude
    )
    print(weather.currently)
    print(weather.daily.data[0].timeLocal)
    # time-based items have a local time
    # version that allows you to convert between the two easily

loop = asyncio.get_event_loop()

loop.run_until_complete(client.forecast(latitude, longitude))

Quick example:

import asyncio
import darksky_async

async def example_function():
  result = await darksky_async.forecast(key, latitude, longitude, exclude=['minutely', 'hourly'], units='si')

loop = asyncio.get_event_loop()

loop.run_until_complete(example_function())

Extra features

All time-based entries for DataPoint have a local version as well. Thanks to PyTz we can convert the datetime to the local time for quicker and easier access of time. All you need to do to access this local time is append Local to any time-based datapoint:

weather = await client.forecast(37.8267, -122.4233)

utc_time = weather.daily.data[0].sunriseTime
>>> '2pm' # Abbreviated for simplicity
local = weather.daily.data[0].sunriseTimeLocal
>>> '6am' # -8 hours behind UTC, this time is accurate for Los Angeles, USA

This libary also keeps a track of how much is due. When running a forecast, you can check the current amount due by doing:

weather = await client.forecast(lat, lon)
print(weather.total_due)

The returned amount will be in dollars as per the terms of service here As a note: this is only the daily cost. We cannot track the actual amount owed due to DarkSky having that information on lock down.

Release files for darksky-async 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darksky-async 1.0.2
File Size Uploaded
darksky_async-1.0.2.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for darksky-async 1.0.2
File Interpreter ABI Platform
darksky_async-1.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 17.8 kB

Release files / darksky_async-1.0.2.tar.gz

Download URL darksky_async-1.0.2.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
50bfb8491b4cc09ae1a9834d0a939e35cd445aff1466816cd38770fa41dbc8ea
BLAKE2b-256 checksum
How to use checksums
6c39d12d5d6ca15e254bb8313a0cb180b90fabc5a882913aebaceb2df1c90303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release files / darksky_async-1.0.2-py2.py3-none-any.whl

Download URL darksky_async-1.0.2-py2.py3-none-any.whl
Size 10.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
df4b75d6b3cdcf9cedf271be4399aed9e1736fa7f31d8086f0738585f6a16b6d
BLAKE2b-256 checksum
How to use checksums
0e4e975a318e88927034f291f36db7078feae6797b165ea54769a4ce6dd70f99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page