Alfred Workflow for Surge

How I built an Alfred workflow that talks to Surge’s HTTP API so I can toggle proxies from the keyboard.

Nov 16, 2020 · 1 min read · 177 Words · -Views -Comments · Software & Tools
Network Tools Productivity 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

Switching Surge modes always felt clunky: mouse to the menu bar, click, click again. AppleScript GUI automation was an option but too cumbersome. When Surge Mac 4.0 shipped with an HTTP API, I saw my chance to automate it via Alfred. Thirty minutes later, I had a workflow.

Pricing

I skipped my old upgrade path and bought a fresh single-device license for Surge Mac 4.0 ($39.99, with a limited-time 20% discount at the time). Full pricing lives on the official site.

Building Blocks

  1. Surge Mac 4.0.0 / iOS 4.4.0 introduced the HTTP API.
  2. Alfred workflows can run shell scripts; I used Node.js for convenience.

Implementation

  1. Enable the HTTP API in Surge:
    http-api = examplekey@0.0.0.0:6171
    
  2. Call the API from the workflow with JavaScript/Node.

Demo

Download the workflow here.

  • No more mousing around—keyboard-driven toggles feel right at home.
  • The author hinted at even more APIs coming; can’t wait.

Limitations

  • The API is still growing. For instance, there’s no endpoint (yet) to query the active profile.

Closing Thoughts

With this setup I can flip Surge modes instantly—perfect for keyboard-centric workflows.

img

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover