I've found it can be quite useful to look at the debug output of the Heroku CLI. In this case, you can get the query string from the environment variables:
DEBUG=1 HEROKU_DEBUG=1 heroku config:get -a mypgapp DATABASE_URL ❖ ruby-2.3.0
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: version
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: commands
heroku-cli/5.2.12-09f3ecc (darwin-amd64) go1.6.2 /Users/bjeanes/.local/share/heroku/cli/bin/heroku cmd: config:get
--> GET /apps/mypgapp/config-vars
<-- 200 OK
<-- {"DATABASE_URL":"postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb"}
postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb
So, you can then translate that into a curl
request and get the value out using jq
:
$ curl -n -H 'Accept: application/vnd.heroku+json; version=3' \
https://api.heroku.com/apps/mypgapp/config-vars | jq .DATABASE_URL
postgres://REDACTED@ec2-174-129-223-35.compute-1.amazonaws.com:5432/dfbe4e6vs4diqb
This is not the API that heroku pg:credentials
uses. It actually used Heroku's own deprecated v2 API.