Help: Custom API methods

Creating custom API methods

To create a custom API method you need to create a rule with an API method criterion:

  1. Create a new rule by clicking on the plus button below the rules list.
  2. Change the type of the second row in the rule editor to “Custom API method”. The row should look like this: A screenshot of a custom API method criteron row in the rule editor
  3. Enter the name of your custom API method into the text field on this row.
  4. Specify the behaviour you want to associate with your custom API method in the same way you would for any other rule (see the section on behaviour of rules for more information)

You might want to create several rules for the same custom API method, each with different additional criteria, e.g. a method called edit might have one rule to define its default behaviour and another to define its behaviour when the shift key is held down. Rules are applied in order, so if you do have multiple rules for the same custom API method you should put the more specific rules before the more general ones, otherwise the general rule will match and be applied before the more specific rules are evaluated.

Using custom API methods

You can call a custom API method in the same way as you would any other API method. For example, if you were to create an API method called edit you would call it by opening the URL x-choosy://edit/ (replacing with whatever URL you wanted the custom API method to apply to).

For more information on calling API methods, including code examples for various languages, see the API documentation on the Choosy web site.