Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aont/560515bbd627b5f60f3cf25559262242 to your computer and use it in GitHub Desktop.

Select an option

Save aont/560515bbd627b5f60f3cf25559262242 to your computer and use it in GitHub Desktop.

End-to-End Workflow for Exporting a Public iOS Shortcut as JSON


1. Publish the Shortcut

  1. Open Shortcuts .app → long-press the shortcut → ShareCopy iCloud Link. Example link:

    https://www.icloud.com/shortcuts/ABC123
    

2. Derive the Metadata Endpoint

Purpose URL Pattern Notes
Human-friendly share URL https://www.icloud.com/shortcuts/<ID> Launches the Add-Shortcut webpage.
Metadata API (preferred) https://www.icloud.com/shortcuts/api/records/<ID> Returns a JSON document with download details.
Alternate (legacy) API https://www.icloud.com/shortcuts/api/v1/records/<ID> Works today but not officially documented—use with caution.

Replace <ID> (ABC123 in the example) to obtain the JSON endpoint.

3. Fetch the JSON

curl -L -o shortcut_meta.json \
     "https://www.icloud.com/shortcuts/api/records/ABC123"

4. Locate the Plist Download URL

In shortcut_meta.json, drill down:

records[0]
 └─ fields
     └─ shortcut
         └─ value
             └─ downloadURL   ← (direct link to .plist)

Tip: jq -r '.records[0].fields.shortcut.value.downloadURL' shortcut_meta.json

5. Download the .plist

plist_url=$(jq -r '.records[0].fields.shortcut.value.downloadURL' shortcut_meta.json)
curl -L -o shortcut.plist "$plist_url"

6. Convert the Plist to JSON

Platform Command
Windows (ipsw utilities) ipsw.exe plist shortcut.plist > shortcut.json
macOS / Linux (built-in) plutil -convert json -o shortcut.json shortcut.plist
Python (cross-platform) Use the full script below.

Reference Implementation (Python 3)

A standalone script that performs all steps above:

#!/usr/bin/env python3
"""
fetch_shortcut.py — Export a public iOS Shortcut as JSON.

Usage:
    python fetch_shortcut.py ABC123  > shortcut.json
"""
import sys, json, plistlib, requests

def api_url(code: str) -> str:
    return f"https://www.icloud.com/shortcuts/api/records/{code}"

def download_plist(code: str) -> bytes:
    meta = requests.get(api_url(code), timeout=30)
    meta.raise_for_status()
    data = meta.json()
    plist_link = (
        data["records"][0]
            ["fields"]["shortcut"]["value"]["downloadURL"]
    )
    plist = requests.get(plist_link, timeout=30)
    plist.raise_for_status()
    return plist.content

def main():
    if len(sys.argv) != 2:
        sys.exit("Usage: python fetch_shortcut.py <ShortcutID>")
    code = sys.argv[1]
    plist_bytes = download_plist(code)
    plist_obj = plistlib.loads(plist_bytes)
    json.dump(plist_obj, sys.stdout, ensure_ascii=False, indent=2)

if __name__ == "__main__":
    main()

Alternative Tools & Variations

Need Candidate Tools / Methods
Scripting Bash (curl + jq), PowerShell (Invoke-WebRequest, ConvertFrom-Json), Node.js (axios, plist)
Batch conversion Run the Python script in a loop; or use xargs with curl + plutil.
Automation on iOS Use another Shortcut that calls the metadata endpoint, followed by Get Contents of URLSet VariableQuick Look.

This outline gives you multiple, non-casual options—from a one-liner to a full Python utility—to retrieve and convert any publicly shared iOS Shortcut into usable JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment