Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@caseywatts
Last active January 31, 2019 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseywatts/bb73f6b5b5b779fb6ac5f39724154713 to your computer and use it in GitHub Desktop.
Save caseywatts/bb73f6b5b5b779fb6ac5f39724154713 to your computer and use it in GitHub Desktop.
Heroku API - Grab ID

Setup

  • brew install jq (jq is like sed for json)
  • put this in your .bashrc or .zshrc
  • pbcopy is an OSX thing (I'm sure there's a linux/windows way to do this too?)
  • You will need the heroku cli api plugin:

Usage

See the notes in the code

# grabid
# grab id from the heroku api endpoint
# and then copy it into clipboard
#
# grabid /addon-services/deployhooks
# grabid /apps/powerful-hamlet-24622
function grabid() {
thingId=$(heroku api get $1 | jq '.id' -r)
echo "endpoint: $1"
echo "id: $thingId"
printf $thingId | pbcopy # printf so no new line
echo 'id copied to clipboard'
}

Other ways to do the same thing (without the copy into clipboard):

  • heroku sudo api get /apps/some-app-name | jq '.id' (sudo is herokai only)
  • heroku apps:info --json -a some-app-name | jq .app.id
@joshwlewis
Copy link

Neato!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment