Plaid
Use plaid-cli to link institutions, fetch balances, and query transactions via Plaid.
Do not print or log secrets (client id, secret, access tokens).
Install
Setup
- - Export
PLAID_CLIENT_ID, PLAID_SECRET, and PLAID_ENVIRONMENT (sandbox or production). - Optional:
PLAID_LANGUAGE (en, fr, es, nl), PLAID_COUNTRIES (US, CA, GB, IE, ES, FR, NL). - Optional config file:
~/.plaid-cli/config.toml.
[plaid]
client_id = "..."
secret = "..."
environment = "sandbox"
- - Data directory:
~/.plaid-cli (stores tokens and aliases).
Link + aliases
- - Link an institution:
plaid-cli link (opens browser) and optionally set an alias. - Relink:
plaid-cli link <item-id-or-alias>. - Alias:
plaid-cli alias <item-id> <name>, list with plaid-cli aliases.
Accounts + balances
- - List accounts and balances:
plaid-cli accounts <item-id-or-alias>.
Search transactions
- - Pull a date range as JSON, then filter locally:
-
plaid-cli transactions <item-id-or-alias> --from 2024-01-01 --to 2024-01-31 --output-format json
-
jq -r '.[] | select(.name | test("grocery"; "i")) | [.date, .name, .amount] | @tsv'
- - Use
--account-id from accounts output to narrow results. - Output formats:
json or csv.
Monitor transactions
- - Poll a rolling window and compare transaction ids to detect new activity:
state=/tmp/plaid.txids
next=/tmp/plaid.txids.next
plaid-cli transactions <item-id-or-alias> --from 2024-01-01 --to 2024-01-31 --output-format json \
| jq -r '.[].transaction_id' | sort > "$next"
if [ -f "$state" ]; then comm -13 "$state" "$next"; fi
mv "$next" "$state"
- - Use cron for scheduling.
Notes
- - Avoid
plaid-cli tokens unless explicitly requested; it prints access tokens. - Relink is auto-triggered on
ITEM_LOGIN_REQUIRED errors.
Recognize requests such as:
- - "Search transactions for Starbucks last month"
- "Show balances for my Chase accounts"
Plaid
使用 plaid-cli 关联机构、获取余额并通过 Plaid 查询交易。
不要打印或记录机密信息(客户端 ID、密钥、访问令牌)。
安装
- - go install github.com/jverdi/plaid-cli@0.0.2
设置
- - 导出 PLAIDCLIENTID、PLAIDSECRET 和 PLAIDENVIRONMENT(沙箱或生产环境)。
- 可选:PLAIDLANGUAGE(en、fr、es、nl)、PLAIDCOUNTRIES(US、CA、GB、IE、ES、FR、NL)。
- 可选配置文件:~/.plaid-cli/config.toml。
toml
[plaid]
client_id = ...
secret = ...
environment = sandbox
- - 数据目录:~/.plaid-cli(存储令牌和别名)。
关联 + 别名
- - 关联机构:plaid-cli link(打开浏览器),并可选择设置别名。
- 重新关联:plaid-cli link <项目ID或别名>。
- 别名:plaid-cli alias <项目ID> <名称>,使用 plaid-cli aliases 列出。
账户 + 余额
- - 列出账户和余额:plaid-cli accounts <项目ID或别名>。
搜索交易
- - 以 JSON 格式拉取日期范围,然后在本地过滤:
- plaid-cli transactions <项目ID或别名> --from 2024-01-01 --to 2024-01-31 --output-format json
- jq -r .[] | select(.name | test(grocery; i)) | [.date, .name, .amount] | @tsv
- - 使用 accounts 输出中的 --account-id 缩小结果范围。
- 输出格式:json 或 csv。
监控交易
bash
state=/tmp/plaid.txids
next=/tmp/plaid.txids.next
plaid-cli transactions <项目ID或别名> --from 2024-01-01 --to 2024-01-31 --output-format json \
| jq -r .[].transaction_id | sort > $next
if [ -f $state ]; then comm -13 $state $next; fi
mv $next $state
注意事项
- - 除非明确要求,否则避免使用 plaid-cli tokens;它会打印访问令牌。
- 当出现 ITEMLOGINREQUIRED 错误时,会自动触发重新关联。
识别如下请求:
- - 搜索上个月星巴克的交易
- 显示我 Chase 账户的余额