This document shows the successful testing of heroku-fetch with HEROKU_API_KEY authentication and oclif commands.
# Install dependencies
npm install
# Build the project
npm run buildTest the basic usage pattern (set HEROKU_API_KEY first):
npx tsx examples/basic-usage.tsOutput:
Fetching apps...
Found 200 apps
Fetching details for app: agile-beyond-18927
App details: {
name: 'agile-beyond-18927',
region: 'us',
stack: 'heroku-24',
created: '2025-06-13T19:38:04Z'
}
Fetching dynos for app: agile-beyond-18927
Found 0 dynos
The oclif command examples demonstrate real-world CLI command usage with automatic HEROKU_API_KEY authentication.
Use the run script to execute commands:
./examples/oclif/run.sh <command> [args...]List all apps with formatted output:
./examples/oclif/run.sh apps-listOutput:
=== Apps (200)
agile-beyond-18927 (us)
ai-models (us)
aistudio-canary (virginia)
...
With JSON output:
./examples/oclif/run.sh apps-list --jsonOutput:
[
{
"name": "agile-beyond-18927",
"region": { "name": "us" },
"stack": { "name": "heroku-24" },
...
},
...
]Get detailed information about a specific app:
./examples/oclif/run.sh apps-info --app agile-beyond-18927Output:
=== agile-beyond-18927
Owner : heroku-dev-tools@herokumanager.com
Region : us
Stack : heroku-24
Web URL : https://agile-beyond-18927-064009444f6e.herokuapp.com/
Git URL : https://git.heroku.com/agile-beyond-18927.git
Maintenance : off
Organization: heroku-dev-tools
With JSON output:
./examples/oclif/run.sh apps-info --app agile-beyond-18927 --jsonOutput:
{
"name": "agile-beyond-18927",
"owner": { "email": "heroku-dev-tools@herokumanager.com" },
"region": { "name": "us" },
"stack": { "name": "heroku-24" },
...
}✅ Automatic authentication - Reads the token from the HEROKU_API_KEY env var
✅ Works with oclif - Full oclif command structure with proper error handling
✅ Multiple output formats - Supports both formatted and JSON output
✅ Error handling - Proper error types and messages
✅ TypeScript ESM - Modern ESM modules with full TypeScript support
✅ Service configuration - Easy switching between Platform API, Data API, etc.
By default the client reads the token from the HEROKU_API_KEY environment
variable. heroku-fetch does not read stored CLI credentials; to authenticate
with credentials saved by the Heroku CLI (native credential store or
~/.netrc), resolve a token with
@heroku/heroku-credential-manager
and pass it to the client.
Enable debug output to see requests and responses:
DEBUG=heroku-fetch:* ./examples/oclif/run.sh apps-listAvailable debug namespaces:
heroku-fetch:request- HTTP requestsheroku-fetch:response- HTTP responsesheroku-fetch:auth- Authenticationheroku-fetch:error- Error details