agentleFS
SiftingIOSiftingIO/siftingio-ai-rules/.cursor/rules/siftingio-core.mdc

siftingio-ai-rules / rules

Cursor rule0 starsChanged 6 months agoMITView on GitHub

SiftingIO API core, base URLs, API-key auth, conventions (identifiers, dates, money, pagination), gzip, error envelope, and rate limits. Read this first.

  • Reads credentials

The file

We split this siftingio-core.mdc into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every REST path is pinned to /v1 (e.g.

    line 24
  2. Distinctive:

    Verify a key is live with the search endpoint:

    line 34
  3. Distinctive:

    Every error response is a JSON body:

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
siftingio-core.mdc
---
description: SiftingIO API core, base URLs, API-key auth, conventions (identifiers, dates, money, pagination), gzip, error envelope, and rate limits. Read this first.
globs: ["**/*"]
alwaysApply: true
---

# SiftingIO Core

SiftingIO is a **unified, multi-asset market-data API**. One key gives you US equities, forex, crypto, commodities, and on-chain DEX data across two surfaces:

- **REST** at `https://api.sifting.io`: fundamentals (SEC filings, XBRL, holdings), historical OHLCV bars, and live snapshots.
- **WebSocket** at `wss://stream.sifting.io/ws/v1`: live ticks and TVL deltas.

It is a **data provider**, not an exchange, broker, or investment advisor. The published price is a robust *reference* fair price (see `siftingio-methodology`).

## Official SDKs & references

SiftingIO ships official SDKs for **Go, Python, and JavaScript/TypeScript** (hub: `https://sifting.io/sdks`, GitHub org: `https://github.com/SiftingIO`). These rules document the underlying REST/WebSocket contract every SDK wraps. Authoritative specs: OpenAPI 3.1 (`https://sifting.io/openapi.yaml`), AsyncAPI 3.0 (`https://sifting.io/asyncapi.yaml`), the LLM context index (`https://sifting.io/llms-full.txt`), and docs at `https://sifting.io/docs`.

## Base URLs & versioning

- REST host: `https://api.sifting.io`
- WebSocket host: `wss://stream.sifting.io/ws/v1`
- Every REST path is pinned to **`/v1`** (e.g. `/v1/fnd/stocks/search`). Within a version, **fields are additive, never removed**. Breaking changes ship under a new version with a deprecation window.

## Authentication

Keys look like `sft_...`. Generate one from the dashboard.

- **REST (preferred):** header `X-API-Key: sft_...`
- **REST (fallback):** query param `?api_key=sft_...` (avoid; query strings leak into logs)
- **WebSocket:** `?key=sft_...` in the URL (browsers can't set headers on the WS handshake), or send `{ "op": "auth", "key": "sft_..." }` as the first frame.

Verify a key is live with the search endpoint:

```bash
# curl
curl -H "X-API-Key: $KEY" \
  "https://api.sifting.io/v1/fnd/stocks/search?q=apple&limit=5"
```

```python
# Python, requests
import os, requests

BASE = "https://api.sifting.io"
session = requests.Session()
session.headers["X-API-Key"] = os.environ["SIFTING_API_KEY"]

r = session.get(f"{BASE}/v1/fnd/stocks/search", params={"q": "apple", "limit": 5})
r.raise_for_status()
print(r.json()["data"])
```

```typescript
// JavaScript / TypeScript, fetch (Node 18+ or browser)
const BASE = "https://api.sifting.io";
const KEY = process.env.SIFTING_API_KEY!;

const res = await fetch(`${BASE}/v1/fnd/stocks/search?q=apple&limit=5`, {
  headers: { "X-API-Key": KEY },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { data } = await res.json();
console.log(data);
```

## Conventions (hold across every endpoint)

- **Identifiers**: Tickers are **case-insensitive** (`AAPL` = `aapl`). CIKs are always **10-digit zero-padded strings** (`"0000320193"`), never strip the leading zeros. Accession numbers come back dashed (`"0000320193-25-000089"`) and are accepted dashed **or** undashed on input.
- **Dates & timestamps**: ISO 8601 everywhere. `filed_at`, `period_end`, `transaction_date` are date-only (`YYYY-MM-DD`). `accepted_at`, `as_of` are full timestamps (`YYYY-MM-DDTHH:MM:SSZ`). Live-tick and bar timestamps (`t`) are **int64 Unix epoch milliseconds** → divide by 1000 before passing to most date libraries.
- **Money & units**: XBRL data carries the unit explicitly: `{ value, unit }` where `unit` is `USD`, `USD/shares` (EPS), `shares`, or `pure` (dimensionless ratios). Don't assume USD.
- **Pagination**: list endpoints take `?limit` (default 50, max 200; default 10, max 25 for `/insiders`) and `?cursor` (opaque, from `meta.next_cursor` on the previous response). **`meta.next_cursor` is null/omitted on the final page.** `meta.total` is the count; `meta.as_of` the snapshot timestamp. Pass the cursor back **verbatim**, never construct it.
- **Envelope**: list/series responses are `{ "data": [...], "meta": {...} }`. A single resource may return the object directly (e.g. company profile).

## Compression (gzip)

Send `Accept-Encoding: gzip`. Every `/fnd/*` and `/hist/*` response comes back gzipped; most HTTP clients add the header and decompress for you. A handful of **heavy endpoints require it** (full XBRL bundles, single-concept and screener queries, and historical bars for stocks/forex/crypto) and return **`406 gzip_required`** without it. With `curl`, pass `-H "Accept-Encoding: gzip" --compressed`.

## Errors

Every error response is a JSON body:

```json
{ "error": "error_code", "message": "human-readable details" }
```

**Switch on the `error` code (snake_case, stable), not the HTTP status.** Status follows standard conventions but the code is the machine-readable contract.

| HTTP | `error` code | Meaning |
| --- | --- | --- |
| 400 | *(raw message)* | Malformed query, invalid cursor, bad limit, missing required parameter |
| 401 | `unauthorized` | API key missing or invalid |
| 403 | *(raw message)* | Authenticated but not entitled, your plan doesn't include this product/market |
| 404 | `unknown_ticker` | `:ticker` not in the SEC's US ticker registry |
| 404 | `unknown_filer` | `:filer` (ticker or CIK) not found |
| 404 | `filing_not_found` | Accession not in this filer's recent-filings window |
| 404 | `no_13f_filings` | Filer has never filed 13F-HR |
| 404 | `not_found` | Concept/period/unit has no data, or symbol absent from live feed |
| 404 | `section_not_found` | Filing section couldn't be extracted (body includes `available`) |
| 404 | `insufficient_filings` | Risk-factors diff needs ≥ 2 10-Ks; filer has fewer |
| 400 | `invalid_section` | `:section` not in the allowed list (body includes `valid_options`) |
| 400 | `invalid_accession_format` | Accession didn't match the dashed/undashed shape |
| 400 | `invalid_date_range` | `to` must be strictly after `from`; range capped at 365 days |
| 406 | `gzip_required` | Heavy endpoint called without `Accept-Encoding: gzip` |
| 422 | `risk_factors_unavailable` | Item 1A couldn't be extracted from one or both 10-Ks |
| 429 | `rate_limit_exceeded` | Per-tier budget exhausted, inspect `Retry-After` |
| 502 | `upstream_error` / `malformed_upstream` | Filings source failed or returned an invalid payload |
| 503 | `stale_snapshot` | Live snapshot older than threshold (default 5s); body carries `last_t`, `server_now` |
| 503 | `upstream_rate_limited` | Filings source throttled our pipeline, retry shortly |

## Rate limits

Every response carries:

- `X-RateLimit-Limit`: token-bucket burst capacity for your tier
- `X-RateLimit-Remaining`: tokens left in the current window
- `Retry-After`: seconds to wait, sent on `429`

On `429 rate_limit_exceeded`, back off for `Retry-After` seconds before retrying.

## Gotchas at a glance

- Branch on the `error` code, **not** the HTTP status.
- `406 gzip_required` on XBRL bundles, single-concept, screener, and historical bars, always send the gzip header on `/hist/*` and heavy `/fnd/*`.
- CIK is a **zero-padded 10-char string**, not an integer.
- Timestamps (`t`) are **milliseconds**, divide by 1000 for `datetime.fromtimestamp` / `new Date(t)` already expects ms.
- Pagination cursors are **opaque**, round-trip them, never parse or build them.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.