Use the Dark Sky weather API in Drafts

I made a quick demo action using the Dark Sky API to grab current weather conditions for your location and display them in a prompt - which also offers a link to the Dark Sky website for more details if needed.

To use the action, you’ll need to sign up for a Free Dark Sky API account and copy-paste in the API Key they give you the first time you run the action.

There’s lots more that could be done with this…the forecast API includes all sorts of detailed information…I just cherry-picked a few useful values to demonstrate.

Install the Dark Sky Forecast action

Once you sign in at Dark Sky, the below shows the API key value you will need to copy and paste into the prompt the first time you run the action:


Is there a way to get the forecast of my current location time and date. Retrieve this info and put this into my current draft? No prompt but directly into the editor written down?

1 Like

I pasted in my API key but the action fails. I tried deleting the action and reinstalling, in case I put the key in wrong (?), but the action seems to have stored that key. How do I start over or re-input the key?

Look at your credentials under Drafts’ internal settings, and Forget the Dark Sky API Key. Next time you run the action you should be prompted again for the key.

Thanks sylumer. That worked!

However I re-input my key and the action still fails.

Have a look at your log against the draft you ran the action against.

I’ve just downloaded the action for the first time, put in my API key and it ran okay for me.

I could not get this to work, then I went to iPhone setting—>privacy—>location services and Drafts was blank. I turned on location services and bam-o it works.

1 Like

Me too! Thanks michaelw.

1 Like

I too am curious if there is a way to adapt this action to automatically input the retrieved Dark Sky information into a current draft.

I currently keep a Bear app journal that I typically update using Drafts. I would like to have the Dark Sky data added at the head of my draft, type an entry and then use my Bear Journal action to send the draft entry to Bear.

I have attempted reading and adjusting the script, but the scripting is beyond my skill. Thanks for any help.

I’m not including the entire script, but the part to change. This example removes the prompt displaying the results, and instead adds that same text to the end of the current draft. Then your URL action after this script step in the same action will include it in the [[body]], [[draft]] or other tags you might be using to send to Bear.

let data = getForecast(lat, lon);
if (data) {
  // See details on all information in response at API docs
  let d = [];
  d.push(`Temperature: ${data.currently.temperature}`);
  d.push(`Summary: ${data.currently.summary}`);
  d.push(`Expected: ${data.minutely.summary}`);
  d.push(`Today's High: ${[0].temperatureHigh}`);
  d.push(`Today's Low: ${[0].temperatureLow}`);
  let weather = d.join("\n");
  // weather var now has the weather data in it.
  // here we'll append it to the end of the current draft...
  draft.content = draft.content + "\n\n" + weather;
  draft.update(); // remove this line if you don't want to save the changes
else {
  alert("Unable to fetch Dark Sky forecast information. Check action log for details");

Thanks for the quick reply! That is exactly what I needed.

With a little adaption to my Bear action, I am now automatically adding weather data to my garden/orchard journal entries.

I set this up a while back
I want to change the longitude & latitude

Where is that set/saved?

If you are relying on this, you might want to take note of the fact that the Dark Sky API is shutting down July 1, 2021.

1 Like

I have been using it for a daily journal - thanks!