# Cơ Bản

> Các lời gọi cơ bản của vnstock-js 2.x với đầu ra mẫu.

```ts
import { vn } from "vnstock-js";
```

`vn` là client mặc định, dùng được ngay. Mọi số tiền tính bằng đồng.

## Giá hiện tại

```ts
const quote = await vn.stock("FPT").price();
```

```json
{
  "symbol": "FPT", "name": "Công ty Cổ phần FPT", "exchange": "HOSE",
  "price": 57500, "change": 400, "changePct": 0.701,
  "ref": 57100, "ceiling": 61000, "floor": 53200, "high": 57800, "low": 56800,
  "volume": 3259200, "value": 186521720000, "matchVolume": 133100,
  "foreignBuyVolume": 512856, "foreignSellVolume": 807002,
  "bids": [{ "price": 57500, "volume": 1000 }], "asks": [{ "price": 57600, "volume": 40600 }]
}
```

Xem đủ các trường ở [Quote](/docs/data/PriceBoardItem).

## Lịch sử giá

```ts
const bars = await vn.stock("FPT").history("6mo");
```

```json
[{ "time": "2026-10-20", "open": 57000, "high": 57800, "low": 56800, "close": 57600, "volume": 3259200, "value": 186521720000 }]
```

Range: `1d 5d 1mo 3mo 6mo ytd 1y 2y 5y max`, hoặc `{ from, to, interval }`. Xem [Lịch sử giá](/docs/key-features/advanced/quote).

## Chỉ số

```ts
const vnindex = await vn.index("VNINDEX").history("1mo"); // điểm, ví dụ close: 1689.12
```

## Nhiều mã một lúc

```ts
const quotes = await vn.prices(["FPT", "VCB", "HPG"]);
const vn30 = await vn.prices({ group: "VN30" });
```

## Tổng quan thị trường

```ts
const m = await vn.market({ exchange: "HOSE" });
console.log(m.index.close, m.liquidity.value, m.breadth.advancing, m.foreign.netValue);
```

## Top tăng, giảm

```ts
const { gainers, losers } = await vn.topMovers({ limit: 10 });
```

## Thông tin công ty

```ts
const fpt = vn.stock("FPT");
const profile = await fpt.company();        // ngành, số cổ phiếu
const holders = await fpt.shareholders();
const events = await fpt.events();          // cổ tức, phát hành, đại hội
```

## Vàng, tỷ giá, tin tức

```ts
const gold = await vn.gold();               // đồng/lượng
const usd = (await vn.fx()).find((r) => r.currencyCode === "USD");
const news = await vn.news({ query: "lãi suất" });
```

## Xử lý lỗi

```ts
try {
  await vn.stock("FTP").price();
} catch (e) {
  console.log(e.code, e.hint); // INVALID_SYMBOL, Did you mean "FPT"?
}
```
