Choosy

Download Choosy version 1.1 or buy now for $10 US

Help: Custom API methods

Creating custom API methods

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

  1. Create a new advanced behaviour rule by clicking on the plus button below the advanced behaviour rules list.
  2. Change the type of the second row in the rule editor to “Custom API method”. The row should look like this: Screenshot of a custom API method row in the advanced behaviour 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 advanced behaviour rule (see the section on behaviour of advanced 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. Advanced behaviour 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/http://www.example.com (replacing http://www.example.com 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.