The publicdotcom-cli lets you interact with your Public brokerage account directly from the terminal. This guide walks through installing the CLI, authenticating, and going from a quote to a placed order without leaving the command line.
Install the CLI
Authenticate
Check a quote
Place and monitor an order
python --version.The recommended way to install the CLI is with pipx, which installs it into an isolated environment and puts the public command on your PATH without affecting any other Python projects:
pipx install publicdotcom-cliAlternatively, install with uv:
uv tool install publicdotcom-cliVerify the installation by printing the help output:
public --helpYou should see a list of available command groups: auth, accounts, market, portfolio, instruments, and order.
Run the login command. It will open a browser window where you authorize the CLI against your Public account, then store the resulting credentials locally:
public auth loginCredentials are saved in your OS keychain by default. The CLI handles token refresh automatically, but you can also trigger it manually:
public auth refreshTo remove stored credentials at any time, run:
public auth logoutMost trading commands require an account ID. Start by listing all accounts linked to your login:
public accounts listThe output shows each account along with its ID, type, and options level. Copy the account ID you want to use and set it as the default so you don't have to pass it on every command:
public accounts set-default YOUR_ACCOUNT_IDYou can verify your holdings at any time with:
public portfolio showBefore placing an order it's good practice to check the current market price. Pass one or more tickers to the quotes command:
public market quotes AAPLYou can quote multiple symbols in a single call:
public market quotes AAPL MSFT TSLAAdd the --json flag to any command to get machine-readable output, useful for scripting:
public market quotes AAPL --jsonThe CLI uses JSON files to describe orders, which makes it easy to version-control and reuse order templates. There are two steps: run a preflight check first, then place the order with the same file.
Save the following as order.json. This example buys 1 share of AAPL at market price, good for the day:
{
"instrument": {
"symbol": "AAPL",
"type": "EQUITY"
},
"orderSide": "BUY",
"orderType": "MARKET",
"expiration": {
"timeInForce": "DAY"
},
"quantity": "1"
}The preflight command validates the order and returns an estimated cost breakdown — including buying-power impact and regulatory fees — without submitting anything live:
public order preflight-single --file order.jsonOnce you've reviewed the preflight output, place the order using the same file:
public order place --file order.jsonImportant
Placing an order through the CLI submits a real order against your live brokerage account. Review the preflight output carefully before running order place.
The command returns an order ID. Use it to check the order status:
public order get ORDER_IDIf you need to cancel before it fills:
public order cancel ORDER_IDQuick Reference
| Command | Description |
|---|---|
public auth login | Authenticate and store credentials |
public auth logout | Remove stored credentials |
public accounts list | List all accounts |
public accounts set-default ID | Set a default account |
public portfolio show | Show portfolio and holdings |
public market quotes AAPL | Get a live quote |
public market option-chain AAPL 2026-06-20 | View options chain |
public order preflight-single --file order.json | Validate an order |
public order place --file order.json | Place an order |
public order get ORDER_ID | Check order status |
public order cancel ORDER_ID | Cancel an open order |
You've installed the CLI, authenticated, and placed your first order. From here you can write shell scripts that combine quotes, preflight checks, and order placement into automated workflows, or pipe --json output into tools like jq for further processing.
If you prefer working directly with the REST API instead of the CLI, the placing your first equity order template covers the same end-to-end flow using raw HTTP requests.
For the full list of commands and flags, run public --help or visit the publicdotcom-cli GitHub repository.