> ## 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.

# CLI

> Use the fcontext terminal CLI for Financial Context market data

# CLI

Use `fcontext` from your terminal to query Financial Context market data, inspect authentication, and produce JSON output for scripts or agents.

The CLI talks to Financial Context by default:

```text theme={null}
https://fcontext.com
```

Commands call read-only market-data endpoints under `/api/market-data/*`. The current CLI focuses on US stock data: symbols must use the `CODE.US` format, and market filters must be `US`.

## Install

<Tabs>
  <Tab title="macOS / Linux">
    Install from the latest GitHub release:

    ```bash theme={null}
    curl -fsSL https://raw.githubusercontent.com/aitaport/fcontext-terminal/main/install | sh
    ```

    The installer downloads the matching release archive, verifies the `.sha256` checksum, and places `fcontext` in `/usr/local/bin`.
  </Tab>

  <Tab title="Windows">
    Install from PowerShell:

    ```powershell theme={null}
    irm https://raw.githubusercontent.com/aitaport/fcontext-terminal/main/install.ps1 | iex
    ```

    The installer downloads the Windows release archive, verifies the checksum, installs `fcontext.exe` under `%LOCALAPPDATA%\Programs\fcontext`, and adds it to your user `PATH`.
  </Tab>

  <Tab title="From source">
    Build locally with Rust:

    ```bash theme={null}
    git clone https://github.com/aitaport/fcontext-terminal.git
    cd fcontext-terminal
    cargo build --release
    ./target/release/fcontext -h
    ```
  </Tab>
</Tabs>

<Note>
  If a release installer cannot find a published release yet, use the source build flow.
</Note>

## Authenticate

Create an API key in Financial Context account settings, then export it:

```bash theme={null}
export FCONTEXT_API_KEY="YOUR_FINANCIAL_CONTEXT_API_KEY"
```

Approved OAuth clients can use an access token instead:

```bash theme={null}
export FCONTEXT_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
```

For staging or local testing, override the base URL:

```bash theme={null}
export FCONTEXT_BASE_URL="https://staging.fcontext.com"
```

Check your configuration:

```bash theme={null}
fcontext auth status
fcontext check
```

## First Commands

```bash theme={null}
# Realtime quotes
fcontext quote AAPL.US MSFT.US

# JSON output for scripts and agents
fcontext quote AAPL.US MSFT.US --format json

# Static instrument information
fcontext static AAPL.US MSFT.US

# Daily candles
fcontext kline AAPL.US --period day --count 100

# Historical candles by date range
fcontext kline history AAPL.US --start 2024-01-01 --end 2024-12-31
```

## Market Data

```bash theme={null}
fcontext market-status
fcontext top-movers --market US --sort hot --count 20
fcontext market-temp US
fcontext market-temp US --history --start 2024-01-01 --end 2024-12-31
fcontext trading session
fcontext trading days US --start 2026-01-01 --end 2026-01-31
fcontext security-list US
```

The `fear-greed` command fetches CNN's public Fear & Greed Index data directly and does not require Financial Context credentials:

```bash theme={null}
fcontext fear-greed
fcontext fear-greed --history-count 90 --indicator-history-count 10 --format json
```

## Company Data

```bash theme={null}
fcontext company AAPL.US
fcontext fundamental-compare AAPL.US
fcontext compare AAPL.US MSFT.US NVDA.US --currency USD
fcontext consensus AAPL.US
fcontext dividend AAPL.US
fcontext forecast-eps AAPL.US
fcontext insider-trades AAPL.US --count 20
fcontext institution-rating AAPL.US
fcontext institution-rating detail AAPL.US
fcontext operating AAPL.US
fcontext shareholder AAPL.US
fcontext shareholder AAPL.US --top --periods 4
fcontext valuation AAPL.US
fcontext valuation AAPL.US --history
```

## News And Events

```bash theme={null}
fcontext news AAPL.US
fcontext filing AAPL.US
fcontext topic AAPL.US
fcontext finance-calendar report --market US
fcontext finance-calendar dividend --market US
```

## Trading Activity

```bash theme={null}
fcontext trades AAPL.US --count 50
fcontext trade-stats AAPL.US
fcontext short-positions AAPL.US
fcontext short-trades AAPL.US
```

## Screeners

```bash theme={null}
fcontext screener strategies --market US
fcontext screener mine --market US
fcontext screener strategy 19
fcontext screener run 19 --count 20
fcontext screener filter pettm:10:50 roe:5: --market US
fcontext screener indicators
```

## Direct Endpoint Access

Use `api get` when you need a supported read-only endpoint before a dedicated command exists:

```bash theme={null}
fcontext api get /api/market-data/market/status --format json
```

The CLI rejects absolute URLs, streaming endpoints, non-US market filters, and unsupported account or trading paths before sending a request.

## Output For Agents

Every command supports JSON output:

```bash theme={null}
fcontext company AAPL.US --format json
```

Use `--schema` to print a machine-readable response schema without authenticating:

```bash theme={null}
fcontext company --schema
fcontext quote --schema
```

Generate shell completions:

```bash theme={null}
fcontext completion zsh > ~/.zfunc/_fcontext
fcontext completion bash > ~/.local/share/bash-completion/completions/fcontext
fcontext completion fish > ~/.config/fish/completions/fcontext.fish
```

## Troubleshooting

| Problem                        | What to check                                                                           |
| ------------------------------ | --------------------------------------------------------------------------------------- |
| `Missing fcontext credentials` | Set `FCONTEXT_API_KEY` or `FCONTEXT_ACCESS_TOKEN`.                                      |
| `fcontext API error (401)`     | Confirm the key or token is active and was copied without extra whitespace.             |
| Non-US symbol rejected         | Use symbols such as `AAPL.US`; non-US markets are intentionally not exposed by the CLI. |
| Need staging                   | Set `FCONTEXT_BASE_URL=https://staging.fcontext.com`.                                   |
| Need request details           | Add `--verbose` to print the request URL and elapsed time to stderr.                    |
