General Primer on API?

Hi everyone,

Sorry for the incredibly naive question, but can anyone point this noob to a good primer on how to get started with using APIs with keyboard maestro?

For background, I want to manipulate my Todoist data - get the # of tasks completed in the last 24 hours, get lists of tasks and projects, send tasks to Todoist, etc. Are there good wikis or youtube windows or something?


As you said "API" I am going to suggest you're probably looking at a URL scheme - unless you want to start automating things like menu item selection.

So I'd look for the target app's URL scheme. Then use KM to GET or POST (as appropriate) using it.

Thanks, Martin. I think what I'm looking for is something even more basic, which is just some training modules on what a URL scheme even is and the set up for GET and POST even is. I realize this isn't exactly a KM question, but googling around for the answers, I'm finding it hard.

1 Like

OK. So now we've established level I hope someone can furnish you with an example.

This may help you get started:

1 Like

As a general starting point, I would google for 3 terms:

  1. Name of service (in this case “Todoist”)
  2. the word “API”
  3. the word “curl”

curl is a very basic and very common command-line tool used for interacting with websites, and is available on Mac, Linux, and now even Windows, so it gives you a good chance that you will find something that you can use with Keyboard Maestro because Keyboard Maestro can use shell commands, and can very easily do things like saving the output of a shell command to a variable that can be used later on. It’s also fairly easy to debug shell scripts in Keyboard Maestro because you can use “Show Result in Window” and see exactly what you are getting.

Once you get a little more comfortable with curl, you will probably be able to use what you learned with curl to adapt to use more native Keyboard Maestro features but learning how to do it in curl gives you the opportunity to use a number of different tools and apps, so it's a good starting point IMO.

Doing this led me to which has curl examples right on the page.


While some apps may offer a real API that uses commands like the Bash curl, I think that there are very few that do so. curl generally requires a web server to receive the commands. As @tjluoma suggests, you should be able to quickly find out just by googling the app name and "curl".

I think what you are referring to is mac automation.

For decades now, AppleScript has been the primary tool for mac automation. In recent times you can also choose from:

If the app has a menu command (or shortcut key) to provide the data you want, then you can usually use KM to get it using the KM Select or Show a Menu Item action and Type a Keystroke action. Of course that will result in the app outputting the results in whatever form/format it normally uses.

AppleScript, and now JXA (since Yosemite) are the primary tools for app automation and control. This does require that the app developer provides for scripting support.
If it does, then you can save the results into an AppleScript variable, and then do whatever you like with it.

You can quickly find out if an app has scripting support by using the File > Open Dictionary menu of Script Editor. OR, as I just learned from Chris @ccstone, you can drag the app file onto the Script Editor icon in the Dock. If it does, you will see a Scripting Dictionary, like this:


You can type select the app name, and then open it ("Choose"), and you will see:

Of course, you can also google app name and "AppleScript" to find examples, if it does support scripting.

AppleScript and JXA work very well with KM, using the Execute Script Actions like Execute an AppleScript action.


JIC you want to learn AppleScript, I'll leave you with this:


If you want to learn JXA, you can start with JXA Resources.

There are many AppleScripts and JXA scripts that have been published in this forum, for a variety of apps. So you might search this forum for app name and AppleScript.

1 Like

Thank you! This is awesome!

1 Like