> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fcontext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 快速開始

> 發起第一筆 Financial Context 市場資料請求

Financial Context 透過 `openapi.fcontext.com` 暴露已認證的 `/api/market-data/*` 市場資料介面。

## 1. 建立憑證

前往 [fcontext.com](https://fcontext.com) 登入 Financial Context，開啟帳戶設定，為外部存取建立 API key。

<Warning>
  請妥善保管 API key。建議使用環境變數或平台的密鑰管理器。
</Warning>

## 2. 請求行情

```bash theme={null}
curl "https://openapi.fcontext.com/api/market-data/quote?symbols=AAPL.US,MSFT.US" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"
```

回應內容會包含所請求標的的行情資料。當前 API 支援 `.US` 標的和 `US` 市場篩選條件。

## 3. 在程式碼中呼叫 API

```javascript theme={null}
const baseUrl = "https://openapi.fcontext.com";
const apiKey = process.env.FCONTEXT_API_KEY;

export async function getQuote(symbols) {
  const params = new URLSearchParams({ symbols: symbols.join(",") });
  const response = await fetch(`${baseUrl}/api/market-data/quote?${params}`, {
    headers: { "x-api-key": apiKey },
  });

  if (!response.ok) {
    throw new Error(`Financial Context request failed: ${response.status}`);
  }

  return response.json();
}
```

## 常用首批請求

```bash theme={null}
# 即時行情
curl "https://openapi.fcontext.com/api/market-data/quote?symbols=AAPL.US" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"

# 公司概況
curl "https://openapi.fcontext.com/api/market-data/fundamental/company?symbol=AAPL.US" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"

# 新聞
curl "https://openapi.fcontext.com/api/market-data/content/news?symbol=AAPL.US" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"

# 選股器
curl "https://openapi.fcontext.com/api/market-data/screener/search?market=US&conditions=pettm:10:50&count=20" \
  -H "x-api-key: YOUR_FCONTEXT_API_KEY"
```

## 方法支援

市場資料介面支援 `GET`。篩選、分頁和其他選項請透過查詢參數傳入。
