Vela for Mac has an automation API built in. It is a small HTTP server inside the browser that lets your scripts open tabs, read pages, click, type and take screenshots, without a driver or an extension. It is off until you turn it on, it listens only on your own Mac by default, and every request needs a key. This quick start takes you from the switch in Settings to a saved screenshot, using nothing but curl.
Turn on the Automation API
- Choose Vela → Settings… from the menu bar, or press ⌘,, and open Automation in the sidebar.
- Switch on Enable Automation API. The status line under it turns green and reads Running on port 1306.
- Under Authentication, click the copy button next to API Key. Vela creates a key for you the first time you enable the API. Generate replaces it with a new one.
These are the settings you start with:
| Setting | Default |
|---|---|
| Port | 1306 |
| Bind Address | Localhost Only (127.0.0.1) |
| API Key | A random 32-character key, made for you |
Once the API is on, it starts again by itself each time you open Vela, until you switch it off.
Make your first request
Open Terminal, store the key in a variable so you do not have to paste it into every command, and ask the browser how it is doing:
export VELA_API_KEY="paste-your-key-here"
curl -H "X-API-Key: $VELA_API_KEY" http://127.0.0.1:1306/api/status
The answer is JSON:
{
"status": "ok",
"tabCount": 3,
"uptime": 12.4,
"version": "1.5.302",
"windowCount": 1
}
If you see Unauthorized: Invalid or missing API key with status 401, the key in your variable does not match the one in Settings. When the API is running, the Automation pane also shows a ready-made Quick Start command with your key filled in, which you can copy as it is.
Open a tab and read the page
Create a tab by sending a URL to /api/tabs:
curl -X POST http://127.0.0.1:1306/api/tabs \
-H "X-API-Key: $VELA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com"}'
Vela opens the tab in one of your open windows (add a windowId to choose which) and answers with the tab as JSON: its id, windowId, title, url, isLoading and a few more fields. Copy the id, because every page request uses it:
TAB="paste-the-tab-id-here"
# Wait until the page has finished loading
curl -X POST http://127.0.0.1:1306/api/tabs/$TAB/wait-for-load-state \
-H "X-API-Key: $VELA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"state":"load"}'
# Read the visible text of the page
curl -H "X-API-Key: $VELA_API_KEY" http://127.0.0.1:1306/api/tabs/$TAB/text
The first call answers {"ready": true, "state": "load"} when the page is done. The second returns the page's text in a text field. To send the same tab somewhere else, post a new URL to /api/tabs/$TAB/navigate with the same {"url": "..."} body.
Save a screenshot
The screenshot endpoint returns the image as base64 inside JSON, in a field called data. Two tools that ship with macOS turn that into a PNG file:
curl -s -H "X-API-Key: $VELA_API_KEY" \
http://127.0.0.1:1306/api/tabs/$TAB/screenshot \
| plutil -extract data raw -o - - \
| base64 --decode > page.png
Swap screenshot for pdf and page.png for page.pdf to save the page as a PDF the same way.
Click, fill in forms and run JavaScript
Page actions take a CSS selector in a JSON body. These are the ones you will use most:
| Request | Body | What it does |
|---|---|---|
POST /api/tabs/:id/click | selector | Clicks the first element that matches. |
POST /api/tabs/:id/fill | selector, value | Sets a field's value and fires its input and change events. |
POST /api/tabs/:id/type | selector, text | Types text into a field one character at a time. |
POST /api/tabs/:id/wait | selector, timeout | Waits until the element appears, 10 seconds unless you say otherwise. |
POST /api/tabs/:id/execute | script | Runs JavaScript in the page and returns its result. |
GET /api/tabs/:id/snapshot | None | Lists headings, readable text and the visible interactive elements. |
DELETE /api/tabs/:id | None | Closes the tab. |
The snapshot is handy when you do not know a page's markup. Each interactive element comes back numbered and stamped with a data-vela-ref attribute, so you can click element seven with the selector [data-vela-ref="e7"] instead of guessing at class names.
The same style of request covers windows, profiles, bookmarks, history, downloads and cookies. The API docs list every endpoint with its parameters.
Listen for events over WebSocket
Polling works, but the browser can also tell you when something happens. Connect a WebSocket client to the same port and pass the key as a query parameter:
const ws = new WebSocket("ws://127.0.0.1:1306/api/events?apiKey=YOUR_KEY");
ws.onmessage = (message) => {
const event = JSON.parse(message.data);
console.log(event.type, event.data);
};
Each message has a type, a data object and a timestamp. Types include tab.created, tab.closed, navigation.changed, page.loading, page.loaded, download.started and download.completed, so a script can wait for a page to finish instead of guessing how long to sleep.
Keep the API safe
The API can do what you can do in the browser, including reading pages you are signed in to. A few habits keep that power on your side:
- Stay on localhost. Leave Bind Address on Localhost Only (127.0.0.1). If you choose All Interfaces, Vela warns you that the API becomes reachable from your network.
- Treat the key like a password. Keep it out of scripts you share and repositories you publish. Send it in the
X-API-Keyheader rather than in the address, where it can end up in logs and shell history. - Rotate when in doubt. Generate makes a new key at once and the old one stops working.
- Switch it off when you are done. With Enable Automation API off, nothing is listening.
Where to go next
With the API running, the built-in reference is one address away: open http://127.0.0.1:1306/api/docs in any browser, or click Open API Manual in the Automation pane. From here:
- Run scripts without a window on screen with hidden and headless mode.
- Give each job its own cookies and sign-ins by opening windows on separate profiles.
- Read how a local API compares with driver-based tools in automating a real browser.