> For the complete documentation index, see [llms.txt](https://docs.alpha-lenz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alpha-lenz.com/en/api-reference/public-api/stock.md).

# Stock

Access stock price data including OHLCV (Open, High, Low, Close, Volume).

**Required Scope:** `read:stock` or `read:all`

## Get Stock Prices

Get OHLCV stock price data for a symbol.

```
GET /api/public/v1/stock/prices/{symbol}
```

### Path Parameters

| Parameter | Type   | Description                   |
| --------- | ------ | ----------------------------- |
| `symbol`  | string | Stock symbol (e.g., "005930") |

### Query Parameters

| Parameter  | Type    | Description                                                |
| ---------- | ------- | ---------------------------------------------------------- |
| `interval` | string  | Time interval: "1day", "1week", "1month" (default: "1day") |
| `limit`    | integer | Number of data points (1-500, default: 100)                |

### Example Request

```bash
curl -X GET "https://api.alpha-lenz.com/api/public/v1/stock/prices/005930?interval=1day&limit=30" \
     -H "X-API-Key: ak_your_key"
```

### Response

```json
{
  "symbol": "005930",
  "company_name": "Samsung Electronics",
  "interval": "1day",
  "data": [
    {
      "datetime": "2024-01-15T00:00:00",
      "open": 71500.0,
      "high": 72000.0,
      "low": 71000.0,
      "close": 71800.0,
      "volume": 15000000
    },
    {
      "datetime": "2024-01-16T00:00:00",
      "open": 71800.0,
      "high": 72500.0,
      "low": 71500.0,
      "close": 72200.0,
      "volume": 12500000
    }
  ],
  "count": 30
}
```

***

## Get Stock Price History

Get historical stock price data with date filtering and pagination.

```
GET /api/public/v1/stock/prices/{symbol}/history
```

### Path Parameters

| Parameter | Type   | Description  |
| --------- | ------ | ------------ |
| `symbol`  | string | Stock symbol |

### Query Parameters

| Parameter    | Type    | Description                              |
| ------------ | ------- | ---------------------------------------- |
| `interval`   | string  | Time interval: "1day", "1week", "1month" |
| `start_date` | string  | Start date filter (YYYY-MM-DD)           |
| `end_date`   | string  | End date filter (YYYY-MM-DD)             |
| `limit`      | integer | Results per page (1-1000, default: 100)  |
| `offset`     | integer | Pagination offset (default: 0)           |

### Example Request

```bash
curl -X GET "https://api.alpha-lenz.com/api/public/v1/stock/prices/005930/history?start_date=2024-01-01&end_date=2024-01-31&limit=100" \
     -H "X-API-Key: ak_your_key"
```

### Response

```json
{
  "symbol": "005930",
  "company_name": "Samsung Electronics",
  "interval": "1day",
  "data": [
    {
      "datetime": "2024-01-02T00:00:00",
      "open": 70000.0,
      "high": 71000.0,
      "low": 69500.0,
      "close": 70500.0,
      "volume": 18000000
    }
  ],
  "count": 22,
  "has_more": false
}
```

### OHLCV Fields

| Field      | Type    | Description       |
| ---------- | ------- | ----------------- |
| `datetime` | string  | ISO 8601 datetime |
| `open`     | float   | Opening price     |
| `high`     | float   | Highest price     |
| `low`      | float   | Lowest price      |
| `close`    | float   | Closing price     |
| `volume`   | integer | Trading volume    |

### Pagination

Use `offset` and `limit` for pagination. Check `has_more` to see if there are more results:

```bash
# First page
GET /stock/prices/005930/history?limit=100&offset=0

# Second page
GET /stock/prices/005930/history?limit=100&offset=100
```
