NAV
shell go

Shortify.pro Api

This is the official api for the Shortify.pro service. The api is free to use and does not require accounts or api keys.

Restrictions On Use

You may use Shortify.pro to shorten any url except urls which provide access to illegal content. This includes any content which violates any laws applicable in the UK, the EU or the USA.

Rate Limit

The api has a rate limit of 6 requests per minute. If you exceed the rate limit your requests will return an error message.

If you would like to request a higher rate limit for your project, please email us at [email protected].

Shortcodes

Create A Shortcode

Shortening a URL

#!/bin/bash

# Execute the curl command and capture the response in a variable
response=$(curl --location 'https://create-shortcode-api.shortify.pro/create' \
  --header 'Content-Type: application/json' \
  --data '{
    "url": "https://example.org/my/url",
    "maxClicks": 0,
    "useWord": false,
    "expireDays": 0,
    "expireHours": 0,
    "expireMinutes": 0
  }')

payload=$(echo "$response" | cut -d '.' -f 2 | base64 -d)
echo "$payload"
package main

import (
  "encoding/base64"
  "encoding/json"
  "fmt"
  "io"
  "net/http"
  "strings"
)

func main() {
  create := createRequest{
    Url: "https://example.org/my/url",
  }

  url := "https://create-shortcode-api.shortify.pro/create"
  method := "POST"

  bytes, _ := json.Marshal(create)
  payload := strings.NewReader(string(bytes))

  client := &http.Client{}
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(res.StatusCode, ":", create.decodeJwtToken(string(body)))
}

type createRequest struct {
  Url           string `json:"url"`
  MaxClicks     int    `json:"maxClicks"`
  UseWord       bool   `json:"useWord"`
  ExpireDays    int    `json:"expireDays"`
  ExpireHours   int    `json:"expireHours"`
  ExpireMinutes int    `json:"expireMinutes"`
}

func (c createRequest) decodeJwtToken(token string) string {
  // Split the token into header, payload, and signature
  parts := strings.Split(token, ".")
  if len(parts) != 3 {
    return "invalid token format"
  }

  // Decode the payload
  payloadBytes, err := base64.RawURLEncoding.DecodeString(parts[1])
  if err != nil {
    return "error decoding payload: " + err.Error()
  }

  // Parse the payload as JSON
  var payload map[string]interface{}
  err = json.Unmarshal(payloadBytes, &payload)
  if err != nil {
    return "Error parsing payload: " + err.Error()
  }

  // Print the decoded payload
  return fmt.Sprintf("%+v\n", payload)
}

To shorten a url you create a shortcode, indicating the url it should redirect to at the point of creation. There are a few options you can use to customise your shortcode.

HTTP Request

POST https://create-shortcode-api.shortify.pro/create

Request Body Parameters

Parameter Required Description
url true The url to be shortened. Include the http prefix
maxClicks false Expire the shortcode after this number of clicks
useWord false Use a simple word instead of a shortcode
expireDays false Optionally expire the shortcode after this many days
expireHours false Optionally expire the shortcode after this many hours
expireMinutes false Optionally expire the shortcode after this many minutes

Max Clicks

You can limit your shortcode to the specified number of clicks. After your short url has been visited more than the specified number of times, it is automatically deleted.

Use Word

Instead of a shortcode eg uc.ax/ab1 you can opt to be assigned a word. It will be something short eg uc.ax/kite.

Expire Time

The expire time can be combined eg. if you supply an expireDays value of 1 and an expireHours value of 12, your shortcode will expire after a day and a half, or 24+12 hours.

Response : JWT Token

A successful response to a shortcode create request has an HTTP 200 status code and contains a jwt token.