Agent skill

Alpaca Broker Sse Events

by alpacahq in alpacahq/alpaca-skills

Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably.

Apache-2.0Auto-check passedBackend & APIs

Install Alpaca Broker Sse Events

skills CLI
$ npx skills add alpacahq/alpaca-skills --skill alpaca-broker-sse-events -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alpacahq/alpaca-skills alpaca-broker-sse-events --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alpacahq/alpaca-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/broker-api/sse-events .claude/skills/alpaca-broker-sse-events && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
alpaca-broker-sse-events
GitHub stars
154
Token cost
~2.3k tokens
SKILL.md length
1,041 words
Files
2
Skills in repo
14
Repo updated
First seen
Licence
Apache-2.0

At a glance

Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably.

  • Works in 9 steps: Why SSE (and why it's simpler than it… → Event streams → Connection → …
  • Building an event consumer for Alpaca lifecycle events in any language
  • SKILL.md covers Reference, 1. Why SSE (and why it's…, 2. Event streams and 3. Connection, plus 6 more sections
  • Reaches docs.alpaca.markets

What it does

Alpaca Broker Sse Events is an agent skill from alpacahq/alpaca-skills. Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably. Covers connection, auth, replay cursors (since/sinceid), heartbeats, reconnection/backoff, ordering, and idempotent processing. Use when building an event consumer for Alpaca lifecycle events in any language.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `reference.md`).

It sits in Backend & APIs, covering Realtime and WebSockets. The repository describes itself as: Agent skills for Alpaca's Trading API and Broker API: drop-in SKILL.md files for AI coding assistants. The licence is Apache-2.0.

When your agent uses it

  • Building an event consumer for Alpaca lifecycle events in any language
  • Tasks that involve Realtime and WebSockets

Example prompts

  • “/alpaca-broker-sse-events”

Workflow steps

9 steps, taken from the step headings in SKILL.md.

  1. Why SSE (and why it's simpler than it looks)
  2. Event streams
  3. Connection
  4. Replay cursors — the feature that prevents data loss
  5. Ordering caveat
  6. Reliability patterns (hard-won)
  7. Idempotent processing pipeline
  8. Per-stream notes
  9. SSE is necessary but not sufficient

What it can do on your machine

Read from SKILL.md and the folder at commit 39111ab. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • docs.alpaca.markets

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Alpaca Broker Sse Events loads about 2.3k tokens when it runs. Until then it costs about 102 tokens; SKILL.md has 1,041 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~102
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alpacahq/alpaca-skills at commit 39111ab, republished under its Apache-2.0 licence (© alpacahq). 1,041 words, ~2,314 tokens.

Download SKILL.mdSave it as .claude/skills/alpaca-broker-sse-events/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
alpaca-broker-sse-events
description
Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably. Covers connection, auth, replay cursors (since/since_id), heartbeats, reconnection/backoff, ordering, and idempotent processing. Use when building an event consumer for Alpaca lifecycle events in any language.

Alpaca Broker API — Real-Time Events (SSE)

Alpaca pushes brokerage lifecycle events over Server-Sent Events: a long-lived HTTP GET that streams text/event-stream. This is not the market-data WebSocket (alpaca-broker-market-data) — different transport, different auth, different reliability model.

Read alpaca-broker-integration first. SSE uses the Broker API host + HTTP Basic auth (same credential as Broker REST).

Reference

  • Guide: https://docs.alpaca.markets/docs/sse-events
  • Live: alpaca-docs MCP → search "SSE Events", then fetch us/sse-events

1. Why SSE (and why it's simpler than it looks)

SSE is plain HTTP. You don't need a special client: open a GET, keep the connection open, and read the body line-by-line. Each event is a data: line containing a JSON object. It is replayable — you can ask for events from a point in the past and seamlessly catch up to live, which makes it far better than naive polling for lifecycle state.

2. Event streams

StreamPathCarries
Account statusGET /v1/events/accounts/statusAccount-property changes: status/crypto_status (SUBMITTED→ACTIVE, ACTION_REQUIRED, REJECTED), plus kyc_results, account_blocked, trading_blocked, cash_interest, options
Journal statusGET /v2/events/journals/statusJNLC/JNLS lifecycle (queued→executed, correct…)
Funding/transfer statusGET /v2/events/funding/statusUnified: Transfer, BankRelationship, WireBank, FundingWallet entities (switch on entity_type)
Trade updatesGET /v2/events/tradesOrder events in the event field: new, fill, partial_fill, canceled, rejected, held, trade_bust, trade_correct… (richer than order status)
Non-trade activitiesGET /v1/events/ntaDividends, interest, fees, splits, ACATs, cash disbursements. entry_type e.g. JNLC/FEE/INT/DIVNRA/CSD; status ∈ executed/correct/canceled

Paths & versions are NOT uniform — verify each. This is exactly the kind of cross-stream inconsistency Alpaca's docs under-communicate:

  • /v2 streams (trades, journals/status, funding/status) use a ULID event_id directly; /v1/events/trades and /v1/events/journals/status are legacy (existing partners only — migrate to v2). /v2/events/trades was previously /v2beta1, now redirected.
  • /v1 streams (accounts/status, nta) are current, not deprecated — there is no v2 yet. Each event carries both an integer event_id and a ULID event_ulid.

Every event carries at (timestamp), account_id, and status_from/status_to (account/journal/funding) or event+order (trades).

3. Connection

GET /v2/events/journals/status?since_id=<last-ulid-you-saw> HTTP/1.1
Host: broker-api.alpaca.markets
Authorization: Basic <base64(key:secret)>
Accept: text/event-stream

Read the response stream and parse data: {…} frames as they arrive. In most languages an off-the-shelf EventSource/SSE client works — just make sure it lets you set the Authorization header on the initial request (the browser EventSource API famously does not; use a server-side SSE library instead).

4. Replay cursors — the feature that prevents data loss

Every stream supports point-in-time replay:

ParamMeaning
since / untilDate or RFC3339 timestamps. URL-encode + in offsets as %2B.
since_id / until_idID cursors. On v2 streams the ID is a ULID. On v1 streams it's the integer event_id.
since_ulid / until_ulidv1 streams only (accounts, nta) — ULID-based cursors, since v1 events carry both an int event_id and a event_ulid.

Rules: since is required if until is set; since_id required if until_id set (same for since_ulid/until_ulid); you can't mix since, since_id, and since_ulid. Without any since cursor, no history is returned — you only get live pushes from now on. Reaching the until bound ends the stream with a 200.

This is the single most important reliability lesson: persist the ID of the last event you successfully processed. On every (re)connect, pass it as your since cursor (since_id on v2; since_ulid or since_id on v1) so Alpaca replays anything you missed during the gap. A consumer that reconnects without a cursor silently drops every event that occurred while it was down.

5. Ordering caveat

Within a millisecond, ULIDs contain a random component, so two events in the same millisecond can sort either way. Alpaca's own guidance: for reconciliation, restart the stream from a since a few minutes before your last event and rely on idempotent processing to absorb the overlap. Don't assume strict total ordering — assume approximate ordering plus dedup.

Show full SKILL.md (459 more words)Show less

6. Reliability patterns (hard-won)

SSE connections drop — networks, load balancers, deploys, and Alpaca-side resets all happen. A production consumer needs:

  1. Heartbeat / silence detection. SSE has no application heartbeat by default. Track lastMessageAt on every frame; if the stream is silent past a threshold (e.g. 5 min), proactively tear down and reconnect — a dead socket often looks "open."
  2. Reconnect with exponential backoff + cap. On error/close, reconnect after a delay that doubles up to a ceiling (e.g. start 1s, cap 60s). Reset the delay on a successful connect.
  3. A single-reconnect guard. Use a flag so an error storm doesn't spawn many concurrent reconnect attempts racing each other.
  4. Always reconnect with since_id = last processed event (see §4).
  5. Process idempotently (see §7) — overlap from replay is expected, not exceptional.
  6. Don't let a side-effect failure kill the stream. Wrap per-event processing in try/catch; log and continue. One bad event (or a downstream outage) must not stop you consuming the rest.

Note: OpenAPI can't fully model SSE, so generated API clients often hang on these endpoints (waiting for a response that never ends). Use a real streaming HTTP/SSE client, not a codegen'd one.

7. Idempotent processing pipeline

The robust shape for each event:

parse → persist a raw event snapshot (keyed on event_id, skip-if-exists)
      → match the local record by Alpaca ID (account_id / journal_id / order_id / transfer_id)
      → update local state under a row lock / guarded by current status
      → fire side effects (notifications, downstream transfers)
      → advance the stored cursor to this event_id
  • Snapshot-first, keyed on event_id. Insert the raw event with an upsert/skip-duplicate on event_id. A duplicate (from replay or an at-least-once redelivery) is then a no-op. This is your dedup boundary.
  • Lock the target row (SELECT … FOR UPDATE or equivalent) when mutating a transfer/order so two events for the same record can't race.
  • Guard transitions by current status — e.g. only act on a transfer that isn't already in a terminal state, so a late/duplicate "executed" doesn't re-trigger a payout.
  • Advance the cursor only after successful processing, so a crash mid-event replays it rather than skipping it (at-least-once, which idempotency makes safe).

8. Per-stream notes

  • Account status: drive onboarding UI and "enable trading" off status_to == ACTIVE. Reject sandbox/paper account IDs in live handlers.
  • Trade updates: new/accepted/pending_new are pre-fill; update local order state on fill/partial_fill/canceled/rejected. Invalidate any cached portfolio/holdings on fills.
  • Journals: remember executed isn't final and correct spawns a new journal ID (see alpaca-broker-journals). Idempotency + ID-keyed snapshots absorb both.
  • Funding/transfer: unified stream across 4 entity types; switch on entity_type. Funding-wallet per-transfer status may still need polling (alpaca-broker-funding-transfers).
  • NTA: dividends/fees/interest/corporate-actions — persist as activity snapshots; these feed balance/portfolio reconciliation.

9. SSE is necessary but not sufficient

Even a perfect consumer can miss events (extended downtime beyond retention, a bug, an un-handled type). Always pair SSE with a periodic reconciliation/heal pass that re-pulls authoritative state (activities, journals, transfers) from Alpaca and upserts it. SSE is for low latency; reconciliation is for correctness. See alpaca-broker-reconciliation-idempotency.

Related skills: correctness backstop → alpaca-broker-reconciliation-idempotency; dedup/idempotency mechanics → alpaca-broker-reconciliation-idempotency; backoff details → alpaca-broker-rate-limits-resilience; market-data streaming (WS, not SSE) → alpaca-broker-market-data.

© alpacahq, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/broker-api/sse-events of alpacahq/alpaca-skills.

  • SKILL.md
  • reference.md

Open the folder on GitHubat commit 39111ab

Compare with similar skills

Alpaca Broker Sse Events next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Alpaca Broker Sse Events compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Alpaca Broker Sse Events this skillalpacahq/alpaca-skills154—~2.3kAutomated safety check: PassApache-2.0
Supabase Development and Debuggingsupabase/agent-skills2.7k3 repos~3.6kAutomated safety check: PassMIT
Use Yaakmountain-loop/yaak19k—~1.9kAutomated safety check: PassMIT
Gemini Live API Devgoogle-gemini/gemini-skills4.3k—~4.6kAutomated safety check: PassApache-2.0
Broker Integrationmarketcalls/openalgo2.8k—~4.7kAutomated safety check: NotesAGPL-3.0
Trigger.dev Realtimepapermark/papermark9.2k—~1.7kAutomated safety check: PassCustom licence

Similar skills

  • Official

    General Supabase skill for database, auth, Edge Functions, Realtime and storage work, plus client libraries, migrations, security audits, debugging and reading logs.

    2.7k GitHub starsUsed in 3 repos~3.6k tokens
    Backend & APIsAuto-check passed
  • Use Yaak

    mountain-loop/yaak

    A skill your agent uses when the user mentions Yaak, a Yaak workspace, or the yaak command, or asks to call, hit, or smoke test HTTP/REST endpoints, save or organize API requests for reuse or manual…

    19k GitHub stars~1.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Gemini Live API Dev

    google-gemini/gemini-skills

    Official

    A skill your agent uses when building real-time, bidirectional streaming applications with the Gemini Live API, or migrating legacy Live models (2.0/2.5/3.1) to Gemini 3.8 Live.

    4.3k GitHub stars~4.6k tokensUpdated 4 days ago
    Backend & APIsAuto-check passed
  • Broker Integration

    marketcalls/openalgo

    Integrate a new Indian broker into OpenAlgo, or modify an existing broker plugin.

    2.8k GitHub stars~4.7k tokensUpdated yesterday
    Backend & APIsAuto-check: notes
  • Trigger.dev Realtime

    papermark/papermark

    Shows how to subscribe to Trigger.dev task runs from the backend and from React for progress indicators, live dashboards, AI response streams and approval waits.

    9.2k GitHub stars~1.7k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Spider King

    aoyunyang/spider-king-skill

    Pure-web protocol reverse skill: turn hostile browser clients into browser-free Python collectors.

    509 GitHub stars~7.3k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed

More from alpacahq/alpaca-skills

All 14 skills in this repo
  • Alpaca Broker Account Onboarding

    alpacahq/alpaca-skills

    Open and manage brokerage accounts via the Alpaca Broker API — account creation, KYC/CIP, identity & disclosures, agreements, document upload (incl.

    154 GitHub stars~2.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Alpaca Broker Funding Transfers

    alpacahq/alpaca-skills

    Move money between an Alpaca brokerage account and the EXTERNAL banking world via the Broker API — ACH relationships, wire recipient banks, classic transfers (deposits/withdrawals), the v1beta…

    154 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Alpaca Broker Integration

    alpacahq/alpaca-skills

    Entry point for integrating with the Alpaca Broker API (plus Market Data and Trading APIs) in any programming language.

    154 GitHub stars~3k tokensUpdated 1 mo ago
    Auto-check passed
  • Alpaca Broker Journals

    alpacahq/alpaca-skills

    Move cash (JNLC) and securities (JNLS) BETWEEN accounts inside your own Alpaca omnibus via the Broker API — single, batch, and reverse-batch journals, the Idempotency-Key header, journal status…

    154 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Alpaca Broker Money Precision

    alpacahq/alpaca-skills

    Handle money and numeric precision correctly with the Alpaca API — numbers-as-strings on the wire, decimals vs floats, rounding/truncation before sending amounts, fractional-share precision, and…

    154 GitHub stars~1.2k tokensUpdated 1 mo ago
    Auto-check passed
  • Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts.

    154 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Alpaca Broker Sse Events

What does Alpaca Broker Sse Events do?

Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably. Alpaca Broker Sse Events is an agent skill from alpacahq/alpaca-skills. Consume Alpaca Broker API real-time event streams over Server-Sent Events (SSE) — account status, journal, transfer/funding, trade, and non-trade-activity events — reliably.

When should I use Alpaca Broker Sse Events?

Alpaca Broker Sse Events fits situations like: building an event consumer for Alpaca lifecycle events in any language; tasks that involve Realtime and WebSockets.

How do I install Alpaca Broker Sse Events in Claude Code?

Run `npx skills add alpacahq/alpaca-skills --skill alpaca-broker-sse-events -a claude-code`. Or copy the skill folder (skills/broker-api/sse-events in alpacahq/alpaca-skills) into .claude/skills/alpaca-broker-sse-events in your project. Claude Code loads it when a task matches its description.

How do I install Alpaca Broker Sse Events in Codex?

Run `npx skills add alpacahq/alpaca-skills --skill alpaca-broker-sse-events -a codex`. Or copy the skill folder (skills/broker-api/sse-events in alpacahq/alpaca-skills) into .agents/skills/alpaca-broker-sse-events in your project. Codex loads it when a task matches its description.

Can I use Alpaca Broker Sse Events in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alpacahq/alpaca-skills --skill alpaca-broker-sse-events -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/alpaca-broker-sse-events, .gemini/skills/alpaca-broker-sse-events, .github/skills/alpaca-broker-sse-events and .opencode/skills/alpaca-broker-sse-events in your project.

What does Alpaca Broker Sse Events need to run?

SKILL.md names no scripts, command-line tools or credentials: Alpaca Broker Sse Events is instructions for the agent only.

Does Alpaca Broker Sse Events access the network?

SKILL.md names 1 domain. In commands or code: docs.alpaca.markets; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Alpaca Broker Sse Events safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Alpaca Broker Sse Events use?

Alpaca Broker Sse Events is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Alpaca Broker Sse Events use?

About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Alpaca Broker Sse Events?

Skills that share tags, products or a category with Alpaca Broker Sse Events: Supabase Development and Debugging (supabase/agent-skills, 2.7k stars), Use Yaak (mountain-loop/yaak, 19k stars), Gemini Live API Dev (google-gemini/gemini-skills, 4.3k stars) and Broker Integration (marketcalls/openalgo, 2.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Alpaca Broker Sse Events?

alpacahq (a GitHub organization) maintains it in alpacahq/alpaca-skills, which has 154 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on September 8, 2026.

Source: alpacahq/alpaca-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.