An unofficial command-line interface for the Tesla Fleet API — control your Tesla from the terminal.
Note: This tool communicates only with the official Tesla Fleet API. It does not collect, transmit, or store any personal data beyond what is necessary to authenticate with Tesla on your behalf.
- 🔑 Token-based authentication (OAuth2 refresh flow)
- 🚗 List vehicles on your account
- 📊 View vehicle status (battery, climate, locks, location, odometer)
- 🔓 Lock / Unlock doors
- ❄️ Climate on / off
- ⚡ Start / Stop charging
- 🌅 Wake vehicle
- 🔄 Heartbeat — refresh access token automatically
- No personal data is included in this repository (no API keys, email addresses, or account-specific configuration).
- No user data is uploaded or shared with any service other than the official Tesla Fleet API.
- All sensitive credentials are stored locally only, in:
~/.tesla-cli/config.json— your Tesla application Client ID and VIN~/.tesla-cli/tokens.json— OAuth access/refresh tokens (mode0600)
Requires Go 1.23+.
git clone https://github.com/lu-zhengda/tesla-cli.git
cd tesla-cli
go build -o tesla ./cmd/teslaMove the binary to a directory on your $PATH if desired:
mv tesla /usr/local/bin/tesla
# or: install it to ~/bin/tesla- Register a Tesla Developer Application at https://developer.tesla.com/
- Obtain an OAuth access token and refresh token via the Tesla authorization flow.
- Create the config directory and populate config files:
mkdir -p ~/.tesla-cli
# config.json — your app credentials and VIN
cat > ~/.tesla-cli/config.json << 'EOF'
{
"client_id": "YOUR_CLIENT_ID",
"vin": "YOUR_VIN"
}
EOF
chmod 600 ~/.tesla-cli/config.json
# tokens.json — your OAuth tokens
cat > ~/.tesla-cli/tokens.json << 'EOF'
{
"access_token": "YOUR_ACCESS_TOKEN",
"refresh_token": "YOUR_REFRESH_TOKEN"
}
EOF
chmod 600 ~/.tesla-cli/tokens.json# List vehicles
tesla vehicles
# Vehicle status
tesla status
# Wake the vehicle
tesla wake
# Lock / Unlock
tesla lock
tesla unlock
# Climate
tesla climate-on
tesla climate-off
# Charging
tesla charge-start
tesla charge-stop
# Refresh token (run periodically or via cron)
tesla heartbeatAll commands support --json for scripting:
tesla status --json | jq '.battery_level'
tesla vehicles --jsonAccess tokens expire. Run tesla heartbeat to refresh automatically using your stored refresh token:
# Manual refresh
tesla heartbeat
# Cron (every 6 hours)
0 */6 * * * /usr/local/bin/tesla heartbeattesla-cli/
├── cmd/tesla/ # main entrypoint
├── internal/
│ ├── api/ # Tesla Fleet API client
│ ├── cmd/ # CLI commands (Cobra)
│ └── config/ # Config & token loading/saving
├── go.mod
└── go.sum
See DISCLAIMER.md for legal notices, warranty disclaimer, and Terms of Service requirements.
See SECURITY.md for credential storage policy and how to report vulnerabilities.
MIT