---
name: darvas
description: Use when building custom trading indicators with Pine Script,
  querying financial data via REST API or MCP, analyzing SEC filings and
  earnings data, or setting up webhooks for real-time market data updates.
  Agents should reach for this skill when working with financial datasets,
  creating chart indicators, or integrating market data into applications.
metadata:
  mintlify-proj: darvas
  version: "1.0"
---

# Darvas Skill

## Product summary

Darvas is a financial data platform with two main components: a **Data API** for querying SEC filings, earnings, financial statements, insider trades, institutional holdings, macro data, and crypto prices; and a **Custom Indicators** system for writing Pine Script indicators that run on Darvas charts. The Data API is available as REST endpoints at `https://darvas.app/api/data/v1` and as an MCP server at `https://darvas.app/api/data/v1/mcp`. Custom indicators are written in Pine Script v5/v6 and run in the Darvas terminal or on servers for alerts and sharing. Authentication uses API keys (format: `dvk_` + 43 characters) sent in the `X-API-KEY` header. See the primary docs at https://docs.darvas.app.

## When to use

**Data API:** Use when you need to fetch financial data programmatically—company facts, SEC filings (10-K, 10-Q, 8-K), insider trades, earnings reports, financial statements (income, balance sheet, cash flow), institutional holdings, IPO data, macro indicators (interest rates, inflation, labor data), or crypto prices. Use the REST API for direct HTTP requests or the MCP server to expose endpoints as tools to AI agents.

**Custom Indicators:** Use when building trading indicators for Darvas charts. Write Pine Script to plot technical analysis, draw support/resistance lines, mark buy/sell signals, or run backtests. Use the Darvas assistant to describe an indicator in plain English and have it written automatically.

**Webhooks:** Use when you need real-time notifications of new data—set up webhook destinations to receive POST events when Darvas stores new filings, earnings, insider trades, or other data types.

## Quick reference

### API Authentication and Plans

| Plan | Monthly Requests | Per-Minute Limit | Webhook Destinations |
| --- | --- | --- | --- |
| Trial | 100 (14 days, once per account) | 10 | none |
| Developer | 1,000,000 | 500 | 10 |
| Business | 10,000,000 | 2,000 | 50 |
| Enterprise | by contract | by contract | by contract |

Create keys in Darvas Settings → Data API. Each key is shown once; store it securely. Revoke keys in the same settings page.

### Common API Endpoints

| Task | Endpoint | Method |
| --- | --- | --- |
| Get company profile | `/company/facts?ticker=AAPL` | GET |
| List SEC filings | `/filings?ticker=AAPL&filing_type=10-K` | GET |
| Get financial statements | `/financials?ticker=AAPL&period=annual` | GET |
| Search line items | `/financials/search/line-items` | POST |
| List insider trades | `/insider-trades?ticker=AAPL` | GET |
| Search filings | `/search` | POST |
| Get stock prices | `/prices/historical?ticker=AAPL` | GET |
| Get macro data | `/macro/interest-rates` | GET |

### Pine Script Basics

```pine
//@version=6
indicator("My Indicator", overlay=false)
len = input.int(14, "Length", minval=1)
rsi = ta.rsi(close, len)
plot(rsi, "RSI", color=color.purple)
hline(70, "Overbought", color=color.gray)
hline(30, "Oversold", color=color.gray)
```

- Use `//@version=6` or `//@version=5`; older versions are auto-converted
- `input.*()` creates user-adjustable parameters
- `plot()`, `hline()`, `bgcolor()`, `barcolor()` draw on the chart
- `ta.*` functions provide technical analysis (RSI, SMA, EMA, MACD, etc.)
- `plotshape()`, `plotchar()`, `label`, `line`, `box` draw annotations
- `strategy()` scripts run with simulated orders shown as arrows

### Pagination

All list endpoints return at most one page per request (100 rows for filings/insider data, 1,000 for macro). Use `limit` to request total rows across pages. Follow `next_page_url` to fetch subsequent pages; the cursor in the URL carries all filters.

```python
url = "https://darvas.app/api/data/v1/insider-trades"
params = {"ticker": "NVDA", "limit": 500}
while url:
    page = requests.get(url, headers={"X-API-KEY": key}, params=params).json()
    # process page["insider_trades"]
    url = page.get("next_page_url")
    params = None  # cursor in next_page_url holds filters
```

### MCP Server

Connect the data API as an MCP server to Claude Code or other agents:

```bash
claude mcp add --transport http darvas https://darvas.app/api/data/v1/mcp --header "X-API-KEY: $DARVAS_API_KEY"
```

Each endpoint becomes a tool named in snake_case: `list_income_statements`, `get_gpu_prices_snapshot`, `search_documents`. Tool calls count as one request against rate limits.

## Decision guidance

| Scenario | Use REST API | Use MCP Server |
| --- | --- | --- |
| Direct HTTP requests from your code | ✓ | |
| Exposing endpoints as tools to AI agents | | ✓ |
| Building a web service | ✓ | |
| Integrating with Claude Code or Cursor | | ✓ |
| Batch processing with Python/JavaScript | ✓ | |

| Indicator Task | Use Pine Script | Use Darvas Assistant |
| --- | --- | --- |
| You know Pine Script syntax | ✓ | |
| You want to describe it in plain English | | ✓ |
| Pasting a TradingView script | ✓ | |
| You need the assistant to fix errors | | ✓ |

| Data Need | Use REST API | Use Search Endpoint |
| --- | --- | --- |
| Fetch specific company financials by ticker | ✓ | |
| Find filings matching a question | | ✓ |
| Get insider trades for a company | ✓ | |
| Search 10-K/10-Q/8-K text for keywords | | ✓ |

## Workflow

### Querying Financial Data

1. **Get an API key:** Sign in to Darvas, go to Settings → Data API, start the free trial (14 days, 100 requests). Copy the key (shown once).
2. **Choose an endpoint:** Read `/llms.txt` at https://docs.darvas.app/llms.txt to find the right endpoint for your data need (filings, earnings, financials, insider trades, macro, etc.).
3. **Build the request:** Use ticker or CIK for companies. Dates are `YYYY-MM-DD`. Pass the key in `X-API-KEY` header.
4. **Handle pagination:** If `next_page_url` is present, follow it to get the next page. The cursor in the URL carries all filters.
5. **Check for errors:** Errors are JSON with a stable `error` code (e.g., `NOT_FOUND`, `RATE_LIMITED`, `QUOTA_EXCEEDED`). On `429`, wait the seconds in `Retry-After`.

### Writing a Custom Indicator

1. **Open the editor:** In Darvas terminal, choose Indicators → Custom indicator (or New custom indicator on mobile).
2. **Write or paste Pine Script:** Use the Code tab. Start with `//@version=6` and `indicator()` declaration. Use `input.*()` for parameters, `plot()` to draw, `ta.*` for technical analysis.
3. **Test on the chart:** Click Add to chart (or Update chart). Errors appear marked on the line. Check Logs for warnings.
4. **Save the indicator:** Click Save and give it a name (up to 64 characters). Each code change becomes a new version.
5. **Adjust inputs:** Use the settings button in the chart legend to change input values without editing code.
6. **Set alerts (optional):** On a saved indicator, choose Set alert to get notifications when it draws marks.
7. **Share (optional):** Choose Share to publish for all Darvas users or with a password.

### Setting Up Webhooks

1. **Add a webhook:** In Darvas Settings → Webhooks, click Add webhook.
2. **Configure:** Give it a name, enter an HTTPS endpoint URL, and tick the event types (Allings, Earnings, Insider trades, etc.).
3. **Save the secret:** Darvas shows the signing secret (`whsec_...`) once. Store it securely.
4. **Verify deliveries:** Each webhook shows its last 25 deliveries with status (Delivered, Pending, Failed). Failed deliveries retry after ~1 minute and ~10 minutes, then stop.
5. **Verify signatures:** Each POST includes `Darvas-Signature: t=<unix seconds>,v1=<hex>`. Verify the signature using your secret before processing.

## Common gotchas

- **API key in browser code:** Never put an API key in client-side code or public repositories. Revoke it immediately if exposed and create a new one.
- **Quota vs rate limit:** Rate limit is per-minute (e.g., 10 requests/min on Trial). Quota is monthly total (e.g., 100 requests in 14 days on Trial). Only successful (2xx) responses count.
- **Pagination cursor:** The `next_page_url` carries all filters. Pass it as-is; do not modify parameters. Set `params = None` after the first request to avoid overriding the cursor.
- **Ticker vs CIK:** Use ticker (e.g., `AAPL`) or CIK (SEC Central Index Key). If both are sent, CIK takes precedence. CIK can have leading zeros; Darvas accepts both.
- **Date format:** Always use `YYYY-MM-DD` for dates. Other formats return `VALIDATION_ERROR`.
- **Pine Script version:** Darvas auto-converts v1–v4 to v5, but the result may differ from TradingView. Always test.
- **NaN in Pine:** `NaN` coordinates in drawing entities throw a `TypeError` and stop the script. Guard with `if (!na(value))` before creating entities.
- **Entity keys:** In Darvas JavaScript, calling `Line("key", opts)` twice with the same key makes the first handle stale. Always keep the new handle.
- **Hidden ta.* state:** Functions like `ta.macd`, `ta.cci`, `ta.dmi` maintain hidden state keyed by length. Call each once per bar on every bar; reuse the result.
- **Webhook failures:** If a webhook's last 50 attempts failed, it is disabled. Delete it and create a new one once your server responds with 2xx.
- **Pine libraries not supported:** `library()` and `import` are refused. Paste the library code inline or use built-in `ta.*` functions.

## Verification checklist

Before submitting work with Darvas:

- [ ] API key is stored securely (server-side, environment variable, not in code)
- [ ] Requests include `X-API-KEY` header or `Authorization: Bearer` token
- [ ] Pagination is handled: follow `next_page_url` until absent
- [ ] Error codes are checked: handle `429` (rate limit/quota), `401` (auth), `404` (not found)
- [ ] Dates are in `YYYY-MM-DD` format
- [ ] Ticker or CIK is provided (not both, or CIK takes precedence)
- [ ] Pine Script has `//@version=6` or `//@version=5` at the top
- [ ] Indicator is saved before setting alerts or sharing
- [ ] NaN values are guarded before creating drawing entities
- [ ] Webhook endpoint is HTTPS and responds with 2xx within 10 seconds
- [ ] Webhook signature is verified using the stored secret

## Resources

- **Full documentation index:** https://docs.darvas.app/llms.txt — comprehensive page-by-page navigation for agents
- **Data API quickstart:** https://docs.darvas.app/data-api/quickstart — make your first API request in two minutes
- **Custom indicators introduction:** https://docs.darvas.app/introduction — write Pine Script indicators, use the assistant, or share indicators
- **MCP server setup:** https://docs.darvas.app/data-api/mcp — connect the data API as tools for AI agents

---

> For additional documentation and navigation, see: https://docs.darvas.app/llms.txt