LimitKit

LimitKit is an event logging system and rate limiting tool for shortcuts. Shortcut developers can use LimitKit to:

  1. Track and log events made in their shortcuts.
  2. Rate limit shortcut operations by calculating whether a set amount of time has elapsed since the last successful log event.

LimitKit

Check out the example shortcuts below that all employ LimitKit:


Download

The latest version of LimitKit can be found on RoutineHub:


Autocuts

LimitKit works especially well with Autocuts — the solution for running shortcuts automatically in the background while you use your iOS 13 device — because it allows background shortcuts to limit the frequency by which they call their primary function by seconds, minutes, hours, days, weeks, months, or even years.

Autocuts works as part of an Open App personal automation. Its configured to run every time the user opens his or her most frequently used apps, such as Mail, Safari, Notes, and Messages.

Autocuts itself can be configured to use LimitKit. To prevent unnecessary calls when switching quickly between apps, consider setting an interval of one minute or greater within Autocuts Admin for Autocuts.

Setting a check frequency for Autocuts


API Documentation

Developers call the LimitKit shortcut with either a string or a dictionary containing the following parameters. Items in bold below are required.

String

Sending a string to LimitKit will perform a track command request for the given event name. LimitKit will return a dictionary containing:

Dictionary

NOTE: If no command is specified in a dictionary, an update call will be made. Be sure to include valid values for interval.

Event Names

The event name string is case-insensitive. Whitespace will be removed from the beginning and end of the line, and the event name must be on a single line. If you are tracking operations for your shortcut, you can consider using unique strings prefixed by the name of your shortcut. For instance:

Properties

You can store a string of text with your track and update calls. LimitKit does not store anything but the previous event in its database. So, if you want to access records of previous track and update calls, you will have to manage them yourself.

Also note that since information stored by shortcuts are readable by all shortcuts, care should be given as to what information you store via LimitKit.


Examples

This section shows four shortcuts that utilize LimitKit:

Example 2: LimitKit Test

Consider the LimitKit Test shortcut. It sends the following request dictionary to LimitKit which returns 0 if the call is made before 60 seconds have elapsed following a successful update request to LimitKit. Keep running the shortcut again, and you will see 0 until 60 seconds have elapsed.

LimitKit will then return 1 and start the countdown again.

{
	"event": "LimitKit Test",
	"interval": 60,
	"unit": "s"
}

Test Shortcut with LimitKit support

Example 2: Auto Low Power Mode

The Auto Low Power Mode shortcut is used with Autocuts to automatically turn on Low Power Mode when your battery reaches a certain percentage. By default, it performs the check once every five minutes thanks to its integration with LimitKit.

{ “event”: “Auto Low Power Mode”, “interval”: 5, “unit”: “m”, }

In Autocuts Admin, create a new Autocut with the following properties:

Now, every 5 minutes, the Auto Low Power Mode shortcut will run and evaluate my current battery level. It it falls below the threshold set by the user, Low Power Mode is enabled. Otherwise, it’s disabled when the battery level rises above the threshold.

Example 3: Auto DND

The Auto DND shortcut works with Autocuts to automatically toggle Do Not Disturb mode when the current time coincides with calendar events whose title or notes field has the string “DND”.

The shortcut uses Get Calendar Events, which can take a variable amount of time depending on how many events are on the device’s calendar. LimitKit can be used to check the calendars every 1 minute instead of every time Autocuts runs.

Auto DND setting Do Not Disturb automatically

Example 4: Location Triggers

A more advanced use of LimitKit comes in the form of the Location Triggers shortcut. In conjunction with Autocuts, Location Triggers runs shortcuts automatically in the background based on your current location while you use your iOS device.

Because retrieving the user’s current location can be a time-consuming and battery hogging operation (especially if Get Current Location is used instead of Get Current Weather / Location of Weather Conditions), LimitKit can be used to restrict location checks every 5-10 minutes.

This interval value is fully configurable by the user by going to the Settings page in Location Triggers:

Test Shortcut with LimitKit support


Application Interface

When LimitKit is launched with no parameters, it displays a menu with the following commands:

Viewing Events

Tapping View Events along with a event name will show you the same information if you called LimitKit with the value command.

Viewing a LimitKit Entry

NOTE: Editing the values and tapping Done does not save the changes back to the LimitKit entry.


Sending Requests to LimitKit

There are two ways you can send a request to LimitKit from the LimitKit shortcut itself.

Request Assistant

Tap on Request Assistant from the LimitKit Home screen to experience a step-by-step guide for creating a LimitKit request. Here’s an example of using the Request Assistant to make a track call.

  1. Tap Request Assistant.
  2. Enter My Event Name.
  3. Tap Track.

The call will be made and the event object will be returned to the user. The date in the event object will be the date when the event was processed by LimitKit.

Sending a track request using the Request Assistant

To make an update call, perform the following steps:

  1. Tap Request Assistant.
  2. Enter My Event Name
  3. Tap Test.
  4. Enter the interval value.
  5. Enter the unit.
  6. Tap Update if you want the entry updated after a successful evaluation. Tap Test if you just want to know if the interval and unit are valid.
  7. The response of 0 or 1 is return by LimitKit.

Creating an update request to LimitKit

Sending a successful update request to LimitKit

Raw Request

The Request Assistant is great for learning how to use LimitKit, but developers may find it faster to use the Raw Request command to send messages to LimitKit.

Tapping on New Raw Request will display a dictionary where you can fill out:

Sending a raw request to LimitKit


Deleting Events

You can delete individual events by sending a delete call the LimitKit for the given event name.

Tap Delete All Events from the LimitKit Home screen to delete all events on the system. You will be asked to confirm twice since this will remove all events that have been tracked by LimitKit since you either installed it or last deleted the entries.


Localization

LimitKit currently supports the English language, but the shortcut is fully ready to be localized. Visit the LimitKit page on GitHub and submit a pull request for a native localization file.