Skip to content

Instantly share code, notes, and snippets.

@anowell
Last active August 29, 2015 14:26
Show Gist options
  • Save anowell/295116b502c51386628b to your computer and use it in GitHub Desktop.
Save anowell/295116b502c51386628b to your computer and use it in GitHub Desktop.
A bash function to simplify repetitive curling with API key and full URL
# Add to .bashrc or .profile or .zshrc or whatever you use... :)
#
# Examples:
# acurl algo/anowell/Pinky -X POST -d '"pondering"' -H "Content-Type: application/json"
# acurl data/.my/some_collection?force=true -X DELETE
function acurl() {
local aroute=$1
local ahost=${ALGORITHMIA_API-https://api.algorithmia.com}
shift
if [[ -z "$ALGORITHMIA_API_KEY" ]]; then
echo "Must set ALGORITHMIA_API_KEY";
else
curl -H "Authorization: Simple $ALGORITHMIA_API_KEY" "${ahost}/v1/${aroute}" $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment