@todoforai/braintree-api
v0.1.0
Published
JSON-first CLI for the Braintree GraphQL API (transactions, customers, vault, refunds, subscriptions)
Readme
Braintree GraphQL API CLI
Independent CLI over the Braintree GraphQL API. It is not an official Braintree/PayPal product. It prints JSON, keeps Braintree's field names unchanged, and requires an explicit --yes for every mutation.
Auth
Get the API keys from Braintree Control Panel → Settings → API. Each key is a public/private pair, sent as HTTP Basic. Sandbox keys come from https://www.braintreepayments.com/sandbox.
printf '%s' "$PRIVATE" | braintree-api auth --public-key "$PUBLIC" --private-key-stdin # { ping } on production, then sandbox
braintree-api whoami # {"authenticated":true,"environment":"sandbox"}The env vars BRAINTREE_PUBLIC_KEY and BRAINTREE_PRIVATE_KEY override the saved keys. Add BRAINTREE_ENVIRONMENT=production for a live key, since env keys default to sandbox. Credentials are stored in ~/.config/braintree-api/credentials.json (0600).
Commands
There are 137 commands, one per root field of the official schema (https://github.com/braintree/graphql-api, Braintree-Version: 2019-01-01). scripts/generate.ts builds them and validates each GraphQL document against that schema. Each argument becomes a JSON option, and each command has a default selection of scalar fields two levels deep.
braintree-api query viewer --select 'merchant { id companyName }'
braintree-api query transactions --input '{"createdAt":{"greaterThanOrEqualTo":"2026-01-01T00:00:00Z"}}' --first 10
braintree-api mutation charge-payment-method --input '{"paymentMethodId":"fake-valid-nonce","transaction":{"amount":"10.00"}}' --yes
braintree-api mutation create-customer --input '{"customer":{"email":"[email protected]"}}' --yes
braintree-api mutation refund-transaction --input '{"transactionId":"dHJh…"}' --yes
braintree-api mutation charge-payment-method --schema # document + input types, offline
braintree-api graphql --query 'query { ping }'Braintree returns errors as HTTP 200 with errors. The CLI treats that as a failure: JSON on stderr, exit 1.
Develop
bun run generate # refresh src/operations.json from the published schema
bun test && bun run test:node