REST API calls from within Keyboard Maestro?

Hi

First of all: Thanks for developing KM! I absolutly love it, since more than a year.

I don't appear to be able to find a missing feature: I would like to trigger REST-API calls directly from within KM. So for example place a PUT to an URL with a body or place a GET from another. Is there a way to do it directly from within KM?

My use case is that I want to to create keyboard shortcuts for my home automation system (habridge).

Of course I could go and loop over a script, but I'd rather not.

Thanks for any help.

lg, Thomas

PS: Without the direct support I would do it vial curl from the commandline with
curl -X PUT http://jelly/api/3cbccd0339a146088bfac2d9e864cc66/lights/7/state -H 'cache-control: no-cache' -d '{ "on": true }'
but as said: Would be a nice feature to place API-calls directly from within KM :slight_smile: )

curl is probably the best answer, it is very versatile.

Agreed, though CURL does the job for 100%, it would be beneficial for me to avoid writing scripts for basic GET/POST requests.

It would be cool to see KM create a nice GUI actions similar to how Workflow/Shortcuts for iOS does it with their “Get Contents of URL” action, maybe someone already created a third party action for this?

Hey Tyler,

See the Get a URL action.

image

-Chris

Get URL doesn't support POST or JSON post request similar to what workflow/shortcuts supports.

Hey @nexgen,

“GET” by definition is completely opposite to “POST”.

Peter clearly doesn't want to mess with this.

But – that doesn't stop you from making a formal feature request.

-Chris

Apple has a good taste of allowing the Get content to have a post method

Hi Rubick, welcome to the Forum.

Could you please provide some context for how that dialog is accessed? "Apple" is not enough of a clue for me to figure it out, and I used to write REST API documentation for Apple, so I'm ahead of most, I think.

That image of his is from the Apple app called Shortcuts. When Shortcuts came out, I considered moving my KM apps to it, but it falls way short in a variety of ways, especially when it comes to control flow.

Hmm, perhaps Rubick is not aware that when Shortcuts is able to do something that KM cannot, he can call a shortcut directly from KM, like this:

image

[quote="Airy, post:9, topic:9041"]
That image ... is from the Apple app ... Shortcuts. ... I considered moving my KM apps to it, but it falls way short in a variety of ways, ...[/quote]

Thanks. I have attempted to use Shortcuts on my iPhone. I am completely spoiled by Shell Scripts, AppleScript, and KBM.

IMHO, Apple's implementation is painfully slow and cumbersome. They have a creation workflow that presumes you know exactly what you are doing from the gate. Incremental development is barely possible, and hardly worth it, because editing an existing shortcut is so awkward. At least on the iPhone.

On Mac, I have to leave that to others. My hardware won't support any OS more recent than Catalina and being retired, I don't have the cashflow to support a hardware upgrade, so if there are some things that Shortcuts can do that KBM can't, without executing Shortcuts, I'll I have to find workarounds. For REST APIs, I'm happy to use curl.