Agent skill

Alpaca Broker Rate Limits Resilience

by alpacahq in alpacahq/alpaca-skills

Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts.

Apache-2.0Auto-check passedBackend & APIs

Install Alpaca Broker Rate Limits Resilience

skills CLI
$ npx skills add alpacahq/alpaca-skills --skill alpaca-broker-rate-limits-resilience -a claude-code

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

GitHub CLI
$ gh skill install alpacahq/alpaca-skills alpaca-broker-rate-limits-resilience --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/rate-limits-resilience .claude/skills/alpaca-broker-rate-limits-resilience && 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-rate-limits-resilience
GitHub stars
154
Token cost
~1.4k tokens
SKILL.md length
589 words
Files
2
Skills in repo
14
Repo updated
First seen
Licence
Apache-2.0

At a glance

Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts.

  • Works in 6 steps: Rate-limit headers — read them on every… → The retry loop (pseudocode) → Bounded concurrency → …
  • Building robust REST clients
  • SKILL.md covers 1. Rate-limit headers — read…, 2. The retry loop (pseudocode), 3. Bounded concurrency and 4. Pagination loops, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Alpaca Broker Rate Limits Resilience is an agent skill from alpacahq/alpaca-skills. Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts. Use when building robust REST clients, bulk/cron jobs, or reconciliation sweeps against Alpaca in any language.

Its SKILL.md is about 1.4k 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 Rate limiting. It works with Alpaca. 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 robust REST clients
  • Reconciliation sweeps against Alpaca in any language

Example prompts

  • “/alpaca-broker-rate-limits-resilience”

Workflow steps

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

  1. Rate-limit headers — read them on every response
  2. The retry loop (pseudocode)
  3. Bounded concurrency
  4. Pagination loops
  5. Timeouts & batch sizing
  6. Resilience checklist for a bulk/cron job

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

    No URLs in SKILL.md.

    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 Rate Limits Resilience loads about 1.4k tokens when it runs. Until then it costs about 82 tokens; SKILL.md has 589 words of instructions outside code blocks.

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

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). 589 words, ~1,450 tokens.

Download SKILL.mdSave it as .claude/skills/alpaca-broker-rate-limits-resilience/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
alpaca-broker-rate-limits-resilience
description
Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts. Use when building robust REST clients, bulk/cron jobs, or reconciliation sweeps against Alpaca in any language.

Alpaca — Rate Limits & Resilience

Alpaca's APIs are rate-limited and occasionally flaky under load. Any client that does more than a handful of calls — especially bulk jobs, backfills, and reconciliation sweeps — needs disciplined retry, backoff, and concurrency control. These patterns are transport-level and apply in any language.

Read alpaca-broker-integration first.

1. Rate-limit headers — read them on every response

Alpaca returns standard headers:

HeaderMeaning
X-RateLimit-Limitrequests allowed in the window
X-RateLimit-Remainingrequests left in the current window
X-RateLimit-Resetunix timestamp (seconds) when the window resets

Parse them on every response, not just on errors. Two uses:

  • Proactive: when Remaining drops below a threshold (e.g. ≤ 50), log a warning and/or slow down — you're about to get throttled.
  • Reactive: on 429, use Reset to wait exactly until the window opens.

Limits vary by endpoint and plan; market-data limits differ from broker limits. Don't hardcode a number — react to the headers.

2. The retry loop (pseudocode)

MAX_ATTEMPTS = 10
INITIAL_DELAY_MS = 1000

for attempt in 1..MAX_ATTEMPTS:
    res = http(request)                      # with a sane timeout (see §5)
    remaining, reset_at = parse_rate_headers(res.headers)
    if remaining <= 50: log_warn("approaching rate limit", reset_at)

    if res.status == 429:
        # wait until the window resets, plus a small buffer
        wait = (reset_at - now()) if reset_at else INITIAL_DELAY_MS * 2^(attempt-1)
        sleep(max(0, wait) + 1000)           # +1s buffer past reset
        continue

    if res.status in (500, 502, 503, 504) or network_error:
        sleep(INITIAL_DELAY_MS * 2^(attempt-1))   # exponential backoff
        continue

    return res                                # success or non-retryable 4xx
raise last_error

Key points:

  • On 429, wait until X-RateLimit-Reset + a ~1s buffer — don't blindly exponential-backoff when the API told you exactly when to retry.
  • Exponential backoff (base * 2^(attempt-1)) for network errors and 5xx. With base 1s and 10 attempts the tail is minutes — fine for background jobs, too slow for user-facing calls (use fewer attempts there).
  • Don't retry non-retryable 4xx (400/403/422) — those won't fix themselves; surface them.
  • Optionally add jitter to backoff to avoid thundering-herd when many workers retry together.

3. Bounded concurrency

Parallelism speeds bulk jobs but is the fastest way to hit limits. Use a fixed worker pool, not unbounded fan-out.

  • Start small (e.g. 5–8 concurrent requests) and tune against the rate-limit headers. A real lesson from production: a pool was reduced from 10 → 5 to ease both Alpaca and downstream-DB load.
  • Cache per-entity reads within a run (e.g. an account's buying power, or a per-account transfer list) so you don't refetch the same thing across items in a batch.
  • For per-item throttling, a small fixed sleep between calls (e.g. 100ms) is a crude-but-effective floor when you can't easily coordinate a pool.
Show full SKILL.md (255 more words)Show less

4. Pagination loops

List endpoints page forward with a token — never assume one response is complete.

  • Activities (/v1/accounts/activities): page via the X-Next-Page-Token response header; loop until it's empty. Use page_size (≤100) and a direction.
  • Market-data bars (/v2/stocks/bars): page via next_page_token in the body → pass back as page_token. Remember limit counts across all symbols and results sort by symbol-then-time, so a single page may contain only the first symbol(s) — keep paging.
  • Wrap each page fetch in the retry loop from §2.
token = null
loop:
    page = fetch(url + (token ? "&page_token="+token : ""))   # via retry loop
    accumulate(page.items)
    token = page.next_token            # header or body, per endpoint
    if not token: break

5. Timeouts & batch sizing

  • Always set an HTTP timeout (e.g. 15–30s). A hung connection without a timeout stalls a whole worker pool. (SSE streams are the exception — they're meant to stay open; see alpaca-broker-sse-events.)
  • Use a shared HTTP client / connection pool rather than constructing one per request, so keep-alive and connection reuse work.
  • When writing reconciliation results to your own store, chunk bulk inserts (e.g. 500 rows per statement) to stay under DB statement-size limits and keep transactions reasonable.

6. Resilience checklist for a bulk/cron job

  • Rate-limit headers parsed every response; proactive warn near the limit.
  • 429 → wait until X-RateLimit-Reset + buffer.
  • Exponential backoff (+ jitter) for 5xx/network; capped attempts.
  • Non-retryable 4xx surfaced, not retried.
  • Bounded worker pool; per-run caching of repeated reads.
  • Pagination loop until the token is empty.
  • HTTP timeout on every call; shared client.
  • Bulk DB writes chunked and idempotent (upsert) — see alpaca-broker-reconciliation-idempotency.
  • Structured logging with a trace/correlation ID per item for debugging partial failures.

Related skills: safe re-runs of jobs → alpaca-broker-reconciliation-idempotency; the heal/poll jobs that use these patterns → alpaca-broker-reconciliation-idempotency; market-data pagination specifics → 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/rate-limits-resilience of alpacahq/alpaca-skills.

  • SKILL.md
  • reference.md

Open the folder on GitHubat commit 39111ab

Compare with similar skills

Alpaca Broker Rate Limits Resilience 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 Rate Limits Resilience compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Alpaca Broker Rate Limits Resilience this skillalpacahq/alpaca-skills154—~1.4kAutomated safety check: PassApache-2.0
Add Hosted Keysimstudioai/sim30k—~3.6kAutomated safety check: PassApache-2.0
Upstash Ratelimit TSupstash/ratelimit-js2k—~313Automated safety check: PassMIT
Repo2skillzhangyanxs/repo2skill246—~3.6kAutomated safety check: PassNone
Better Auth Security Best PracticesEpicenterHQ/epicenter4.8k—~896Automated safety check: PassCustom licence
Dload Fetch Toolphp-internal/dload105—~1.1kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Add Hosted Key

    simstudioai/sim

    Add hosted API key support to a tool so Sim provides the key (metered and billed to the workspace) when a user has not brought their own.

    30k GitHub stars~3.6k tokensUpdated today
    Backend & APIsAuto-check passed
  • Upstash Ratelimit TS

    upstash/ratelimit-js

    Official

    Lightweight guidance for using the Redis Rate Limit TypeScript SDK, including setup steps, basic usage, and pointers to advanced algorithm, features, pricing, and traffic‑protection docs.

    2k GitHub stars~313 tokensUpdated 16 days ago
    Backend & APIsAuto-check passed
  • Repo2skill

    zhangyanxs/repo2skill

    Convert GitHub/GitLab/Gitee repositories into comprehensive OpenCode Skills using embedded LLM calls with multiple mirrors and rate limit handling

    246 GitHub stars~3.6k tokensUpdated 7 mo ago
    Backend & APIsAuto-check passed
  • Better Auth security hardening: rate limits, secrets, CSRF, trusted origins, cookies, sessions, OAuth tokens, and audit logging.

    4.8k GitHub stars~896 tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Dload Fetch Tool

    php-internal/dload

    Get a CLI tool — native binary or PHAR — from a GitHub release into a project folder with dload (vendor/bin/dload).

    105 GitHub stars~1.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • API Gateway

    itsmostafa/aws-agent-skills

    AWS API Gateway for REST and HTTP API management. An agent skill from itsmostafa/aws-agent-skills.

    1.2k GitHub stars~2.2k tokensUpdated 5 days 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
  • Keep local state correct against the Alpaca Broker API — idempotency keys, ID-keyed upserts, event snapshotting and dedup, polling rails that have no events, nightly reconciliation/heal jobs, status…

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

Works with

Categories

Questions about Alpaca Broker Rate Limits Resilience

What does Alpaca Broker Rate Limits Resilience do?

Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts. Alpaca Broker Rate Limits Resilience is an agent skill from alpacahq/alpaca-skills. Make Alpaca API clients resilient — rate-limit header handling, HTTP 429 backoff, exponential retry, bounded concurrency/worker pools, pagination loops, batch sizing, and timeouts.

When should I use Alpaca Broker Rate Limits Resilience?

Alpaca Broker Rate Limits Resilience fits situations like: building robust REST clients; reconciliation sweeps against Alpaca in any language.

How do I install Alpaca Broker Rate Limits Resilience in Claude Code?

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

How do I install Alpaca Broker Rate Limits Resilience in Codex?

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

Can I use Alpaca Broker Rate Limits Resilience 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-rate-limits-resilience -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-rate-limits-resilience, .gemini/skills/alpaca-broker-rate-limits-resilience, .github/skills/alpaca-broker-rate-limits-resilience and .opencode/skills/alpaca-broker-rate-limits-resilience in your project.

What does Alpaca Broker Rate Limits Resilience need to run?

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

Does Alpaca Broker Rate Limits Resilience access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Alpaca Broker Rate Limits Resilience 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 Rate Limits Resilience use?

Alpaca Broker Rate Limits Resilience 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 Rate Limits Resilience use?

About 1.4k tokens (SKILL.md is roughly 5.8k 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 Rate Limits Resilience?

Skills that share tags, products or a category with Alpaca Broker Rate Limits Resilience: Add Hosted Key (simstudioai/sim, 30k stars), Upstash Ratelimit TS (upstash/ratelimit-js, 2k stars), Repo2skill (zhangyanxs/repo2skill, 246 stars) and Better Auth Security Best Practices (EpicenterHQ/epicenter, 4.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 Rate Limits Resilience?

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.