Last active
August 29, 2015 14:26
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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