Skip to content

Instantly share code, notes, and snippets.

@hashworks

hashworks/kutt.sh

Created Nov 6, 2020
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
}
@hashworks

This comment has been minimized.

Copy link
Owner Author

@hashworks hashworks commented Nov 6, 2020

kutt "https://github.com"

{
  "id": "accefebc-f139-4f08-8b6a-e45b89ce0873",
  "address": "NFJ",
  "description": null,
  "banned": false,
  "password": false,
  "expire_in": null,
  "target": "https://github.com",
  "visit_count": 0,
  "created_at": "2020-11-06T17:26:22.533Z",
  "updated_at": "2020-11-06T17:26:22.533Z",
  "link": "https://kutt.it/NFJ"
}

kutt

{
  "total": 1,
  "limit": 10,
  "skip": 0,
  "data": [
    {
      "id": "accefebc-f139-4f08-8b6a-e45b89ce0873",
      "address": "NFJ",
      "banned": false,
      "created_at": "2020-11-06T17:26:22.533Z",
      "updated_at": "2020-11-06T17:26:22.533Z",
      "password": false,
      "description": null,
      "expire_in": null,
      "target": "https://github.com",
      "visit_count": 0,
      "domain": null,
      "link": "https://kutt.it/NFJ"
    }
  ]
}

kutt delete accefebc-f139-4f08-8b6a-e45b89ce0873

{
  "message": "Link has been deleted successfully."
}
$ kutt "https://gist.github.com" | jq -r '.link'`
https://kutt.it/7zw
@fabianski7

This comment has been minimized.

Copy link

@fabianski7 fabianski7 commented Feb 22, 2021

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