Making API Requests with iOS Shortcuts


My partner and me share our expenses via splitwise and I’ve got a reoccurring transaction with the same amount and description.
But the service has no integrations for this behavior, and every expense has to be inserted manually.

But with iOS Shortcuts it’s really easy to make API requests, so we can work around this!

After a quick web search I found this existing shortcut on reddit, this works, but it requires python scripting via Pythonista 3, which is a paid application.

As with anything I want to reduce any overhead and simplify as much as possible.
Thankfully we can just use the Get Contents Of URL action to trigger our API directly 🙌.

Register your splitwise API key

To interact with the splitwise API you have to register an application here.

After doing so generate a new API key by clicking the generate api key button on your application page.

This will get an API key which you can use in your API call.

You can test your API key in the chrome console like this:

js
fetch("https://secure.splitwise.com/api/v3.0/get_expenses", {
  method: "GET",
  headers: {
    Authorization: "Bearer YOUR_TOKEN",
    "Content-Type": "application/json",
  },
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

This will also help you later to get the group_id, which is needed for adding a new expense.

Creating the shortcut

Add a new shortcut with a Get Contents Of URL action

Now when you expand the action you can choose if you’re doing a POST / GET and attach any headers or body.

Just adapt your needed attributes which are documented at the splitwise api docs.

To get the group_id, query the snippet from above and pick the key from one of the expenses.

Now you can add the shortcut to your homescreen, and with one tap the transaction will be added to your group 💸.

Download the shortcut

Here’s the final shortcut to directly open on IOS:

Download Shortcut