Skip to content

Instantly share code, notes, and snippets.

@MrNice
Created December 2, 2015 18:48
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 MrNice/a16346049cd288657ab6 to your computer and use it in GitHub Desktop.
Save MrNice/a16346049cd288657ab6 to your computer and use it in GitHub Desktop.
API Peek
# get these into your shell somehow
# apI PeeK: Look at an API response and temp save it
function ipk {
echo "Don't use the output flag from curl as it redirects"
curl "$@" | python -m json.tool | tee "apipeek.json" | less
}
# I PicK UP: rename the peeked api response (just partially applied mv)
function ipkup {
mv apipeek.json $1
}
# I PeeK ON: ipk + ipkup. Don't give cURL the output -O flag
function ipkon {
echo "First argument is filename, rest goes to curl"
ipk "${@:2}"
ipkup $1
}
# usage
ipkon pokemon.json http://pokeapi.co/api/v1/pokedex/1/
ipkon blastoise.json http://pokeapi.co/api/v1/pokemon/9/
# Note: ipk ipkup ipkon can be typed right handed on American QWERTY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment