Skip to content

Instantly share code, notes, and snippets.

@hashworks
Created November 6, 2020 17:25
Embed
What would you like to do?
BASH function for kutt.it URL shortener services
KUTT_HOST="https://kutt.it"
KUTT_API_KEY="API_KEY"
kutt() {
if [[ "$1" == "delete" ]] && [[ -n "$2" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
-X DELETE \
"$KUTT_HOST/api/v2/links/$2" | jq
elif [[ -z "$1" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
"$KUTT_HOST/api/v2/links" | jq
elif [[ "$1" != "help" ]] && [[ "$1" != "--help" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
-H "Content-Type: application/json" \
--data "{
\"target\": \"$1\",
\"password\": \"$2\",
\"expire_in\": \"$3\",
\"description\": \"$4\"
}" \
"$KUTT_HOST/api/v2/links" | jq
else
echo "kutt"
echo "kutt help"
echo "kutt <target-url> [<password> <expire_in> <description>]"
echo "kutt delete <uuid>"
return 2
fi
}
@fabianski7
Copy link

curl -s -H "X-API-KEY: $KUTT_API_KEY" \
			-H "Content-Type: application/json" \
			--data "{
				\"target\": \"$1\",
				\"password\": \"$2\",
				\"expire_in\": \"$3\",
				\"description\": \"$4\",
				\"domain\": \"your-custom-domain.tld\"
			}"

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