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.
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?
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.
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.
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
// https://darksky.net/dev/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: ${data.daily.data[0].temperatureHigh}`);
d.push(`Today's Low: ${data.daily.data[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");
}