> ## 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`。筛选、分页和其他选项请通过查询参数传入。
