# Anyfinancial Realtime API Data Us

> Self-contained US direct/recent market data access under AnyFinancial. Use for latest quotes, recent bars, latest news, today OHLC, and point fundamentals.

- Skill: `rebyteai/anyfinancial-realtime-api-data-us` (Agent Skill)
- Install (CLI): `npx skillmds@latest add rebyteai/anyfinancial-realtime-api-data-us`
- Raw SKILL.md: https://api.skillmd.com/api/skills/rebyteai/anyfinancial-realtime-api-data-us/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: rebyteai (https://skillmd.com/u/rebyteai)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/rebyteai/anyfinancial-realtime-api-data-us

---


# US Real-time/API Data

This sub-skill is self-contained. It recreates the US point lookup behavior in
AnyFinancial itself and does not depend on external skill repos.

## Use For

- Latest or current US stock price.
- Recent intraday OHLCV bars.
- Latest US ticker-specific news.
- Latest point fundamentals.
- Today's OHLC aggregated from recent intraday bars.

## Authentication

Use the Rebyte sandbox token and relay URL:

```bash
AUTH_TOKEN=$(/home/user/.local/bin/rebyte-auth)
API_URL=$(python3 -c "import json; print(json.load(open('/home/user/.rebyte.ai/auth.json'))['sandbox']['relay_url'])")
```

Requests use:

```text
POST $API_URL/api/data/financial/sql
Authorization: Bearer $AUTH_TOKEN
Content-Type: application/json
```

The request body is JSON:

```json
{"sql":"SELECT ...","parameters":[]}
```

## Local Commands

The bundled CLI builds the SQL and sends it through the Rebyte relay:

```bash
python3 ../scripts/anyfinancial_api_data.py us latest-price AAPL
python3 ../scripts/anyfinancial_api_data.py us latest-bars AAPL --limit 10
python3 ../scripts/anyfinancial_api_data.py us latest-news TSLA --limit 5
python3 ../scripts/anyfinancial_api_data.py us fundamentals AAPL --limit 1
python3 ../scripts/anyfinancial_api_data.py us today-ohlc AAPL 2026-07-02
```

Run these from `realtime-api-data/us/`. From the repository root, use:

```bash
python3 realtime-api-data/scripts/anyfinancial_api_data.py us latest-price AAPL
```

## SQL Patterns

### Latest Price

```sql
SELECT ticker, t, o, h, l, c, v
FROM us.bars_1m
WHERE ticker = 'AAPL'
ORDER BY t DESC
LIMIT 1
```

### Latest Bars

```sql
SELECT ticker, t, o, h, l, c, v
FROM us.bars_1m
WHERE ticker = 'AAPL'
ORDER BY t DESC
LIMIT 10
```

### Latest News

```sql
SELECT title, published_utc, tickers, content
FROM us.news
WHERE ARRAY_CONTAINS(tickers, 'TSLA')
ORDER BY published_utc DESC
LIMIT 5
```

### Latest Fundamentals

```sql
SELECT *
FROM us.fundamentals
WHERE ARRAY_CONTAINS(tickers, 'AAPL')
ORDER BY end_date DESC
LIMIT 1
```

### Today's OHLC From Intraday Bars

```sql
WITH day_bars AS (
  SELECT t, o, h, l, c, v
  FROM us.bars_1m
  WHERE ticker = 'AAPL'
    AND t >= to_timestamp('2026-07-02T00:00:00')
    AND t < to_timestamp('2026-07-02T23:59:59')
),
agg AS (
  SELECT date_trunc('day', MIN(t)) AS day,
         MIN(t) AS first_bar,
         MAX(t) AS last_bar,
         MIN(l) AS low,
         MAX(h) AS high,
         SUM(v) AS volume
  FROM day_bars
),
open_row AS (SELECT o AS open FROM day_bars ORDER BY t ASC LIMIT 1),
close_row AS (SELECT c AS close FROM day_bars ORDER BY t DESC LIMIT 1)
SELECT day, first_bar, last_bar, open, high, low, close, volume
FROM agg CROSS JOIN open_row CROSS JOIN close_row
```

## Response Handling

Successful responses are JSON. Rows may appear in `data`, `rows`, `result`, or
`results`; if the body is an array, treat it as the row list. Preserve returned
timestamps in the user-facing answer; include source fields only when the
provider returns them.

Errors may include `success: false`, `error`, `message`, or `detail`. Report the
HTTP/provider message exactly and adjust the SQL once; do not retry the same
failing query.

## Usage Rules

- For direct lookups, keep queries scoped to one ticker and a small `LIMIT`.
- For latest/current requests, query the API; do not answer from memory.
- If a table or column is uncertain, use `../../data/SKILL.md` to run catalog and
  schema discovery first.
- Use DataFusion SQL syntax.
- Include the bar/news/fundamentals timestamp in the answer.

## Do Not Use For

- Event-driven strategy simulation. Use `../../backtesting/SKILL.md`.
- Canonical Rebyte Financial Data Service SQL for backtest data. Use
  `../../data/SKILL.md` during the Backtesting data phase.
- Long-form financial research; AnyFinancial Real-time/API Data only retrieves
  provider data.

