DarkSky.jl v0.1

Mar 26, 2018 · 493 words · 3 minutes read darkskyjuliapackages

I’m very happy to announce the initial release of DarkSky.jl, a Julia package for the Dark Sky API. The Dark Sky API provides weather forecasts, current conditions, and historical data with global coverage. DarkSky.jl provides access to the Dark Sky API through Julia.


DarkSky.jl is registered as an official package, so you can install it as normal:


You can install the development version from GitHub:


The Dark Sky API requires an API key and DarkSky.jl expects your API key to be stored as an environment variable named DARKSKY_API_KEY. You can request an API key from the Dark Sky Developer Documentation page.


The basic usage is to request the current weather forecast (a Forecast Request) or the observed or forecast weather conditions for a datetime in the past or future (a Time Machine Request).

To make either a Forecast Request or Time Machine Request, use the forecast function.

julia> using DarkSky

julia> response = forecast(42.3601, -71.0589, DateTime(2018, 3, 26, 16, 0, 0));

The response is a DarkSkyResponse type, which has the following properties:

  • latitude - The requested latitude.
  • longitude - The requested longitude.
  • timezone - The IANA timezone name for the requested location.
  • currently - A data point containing the current weather conditions at the requested location. (optional)
  • minutely - A data block containing the weather conditions minute-by-minute for the next hour. (optional)
  • hourly - A data block containing the weather conditions hour-by-hour for the next two days. (optional)
  • daily - A data block containing the weather conditions day-by-day for the next week. (optional)
  • alerts - An alerts array, which, if present, contains any severe weather alerts pertinent to the requested location. (optional)
  • flags - A flags object containing miscellaneous metadata about the request. (optional)

These properties can be accessed using functions with the same names.

For example the hour-by-hour weather conditions can be accessed using the hourly function, which returns a Dict.

julia> weather = hourly(response)
Dict{String,Any} with 3 entries:
  "summary" => "Clear throughout the day."
  "icon"    => "clear-day"
  "data"    => Any[Dict{String,Any}(Pair{String,Any}("visibility", 9.59),Pair{S…

julia> weather["summary"]
"Clear throughout the day."

Once you have the data, you can the plot it (or do whatever you like)!

julia> using Plots

julia> using Base.Dates

x = [unix2datetime(x["time"]) for x in hourly(response)["data"]];

julia> y = [x["temperature"] for x in hourly(response)["data"]];

julia> plot(x, y,
     title="Hourly temperature",
     xlabel="Timestamp", ylabel="Temperature (°F)",
     shape=:circle, color=:blue, label="Temperature", legend=false,

julia> savefig("static/images/darksky-hour-by-hour.png")

What’s next

As it turns out, DarkSky.jl v0.1.0 contains a mistake that prevents forecast from correctly fufilling a Time Machine Request (it returns the current conditions). So DarkSky.jl v0.1.1 is already tagged on GitHub and awaiting release with the fix.

Currently DarkSky.jl contains few features – it really only facilitates the API request and defines a type for the response. In future releases, I plan to define additional types (e.g. Data Point, Data Block) and extend functionality so the data is easy to work with.

Comments, issue reports, and contributions are welcome on the DarkSky.jl GitHub repo.