shri.ink API Documentation

Integrate URL shortening into your applications with our simple API

Create Short URL
Create a new shortened URL with optional parameters

Endpoint

POST https://shri.ink/api/create

Request Body

{
  "url": "https://example.com/long-url",           // Required
  "customPath": "my-custom-path",                  // Optional
  "secretKey": "your-secret-key",                  // Optional
  "expiresAt": "2023-12-31T23:59:59Z",             // Optional ISO 8601 date
  "expirationRedirectUrl": "https://example.com",  // Optional, URL to redirect to after expiration
  "password": "access-password",                   // Optional, password protection
  "maxClicks": 100,                                // Optional, maximum number of clicks
  "utmParams": {                                   // Optional, UTM parameters
    "utm_source": "newsletter",
    "utm_medium": "email",
    "utm_campaign": "summer_sale"
  },
  "geoTargeting": {                                // Optional, country-specific redirects
    "US": "https://example.com/us",
    "GB": "https://example.com/uk",
    "CA": "https://example.com/ca"
  },
  "useMiddleman": true,                            // Optional, use redirect page
  "useCaptcha": true                               // Optional, require CAPTCHA (only if useMiddleman is true)
}

Response

{
  "success": true,
  "data": {
    "shortId": "abc123",
    "shortUrl": "https://shri.ink/abc123",
    "originalUrl": "https://example.com/long-url",
    "createdAt": "2023-06-15T10:30:00Z",
    "expiresAt": "2023-12-31T23:59:59Z",           // Only if expiration was set
    "expirationRedirectUrl": "https://example.com" // Only if redirect was set
  }
}

Error Response

{
  "success": false,
  "error": "Error message"
}
API Content Types
The API supports both JSON and form data

Supported Content Types

  • application/json - Send data as JSON
  • application/x-www-form-urlencoded - Send data as form fields

Form Data Notes

When using form data:

  • Boolean values should be sent as strings: "true" or "false"
  • Nested objects (like utmParams or geoTargeting) should be sent as JSON strings
  • For bulk operations, the urls array should be sent as a JSON string
Get URL Analytics
Retrieve analytics for a shortened URL

Endpoint

GET https://shri.ink/api/analytics/{shortId}

Headers

{
  "X-Secret-Key": "your-secret-key"  // Required if URL is protected
}

Response

{
  "success": true,
  "data": {
    "shortId": "abc123",
    "originalUrl": "https://example.com/long-url",
    "createdAt": "2023-06-15T10:30:00Z",
    "expiresAt": "2023-12-31T23:59:59Z",
    "expirationRedirectUrl": "https://example.com",
    "isExpired": false,
    "isPasswordProtected": true,
    "maxClicks": 100,
    "clicksRemaining": 42,
    "hasGeoTargeting": true,
    "hasUtmParams": true,
    "totalClicks": 58,
    "dailyClicks": [
      { "date": "2023-06-15", "clicks": 10 },
      { "date": "2023-06-16", "clicks": 32 }
    ],
    "topReferrers": [
      { "referrer": "google.com", "count": 15 },
      { "referrer": "twitter.com", "count": 12 }
    ],
    "topCountries": [
      { "country": "US", "count": 20 },
      { "country": "IN", "count": 8 }
    ],
    "topBrowsers": [
      { "browser": "Chrome", "count": 30 },
      { "browser": "Safari", "count": 15 }
    ],
    "topDevices": [
      { "device": "Desktop", "count": 35 },
      { "device": "Mobile", "count": 23 }
    ]
  }
}
Verify Password
Verify a password for a password-protected URL

Endpoint

POST https://shri.ink/api/verify-password/{shortId}

Request Body

{
  "password": "your-password"  // Required
}

Response

{
  "success": true,
  "message": "Password verified successfully"
}

Error Response

{
  "success": false,
  "error": "Invalid password"
}
Generate QR Code
Generate a QR code for a shortened URL

Endpoint

GET https://shri.ink/api/qr/{shortId}?size=200

Query Parameters

size: Number (optional, default: 200) - Size of the QR code in pixels

Response

Returns a PNG image of the QR code

Check URL Health
Check if a URL is valid and accessible

Endpoint

POST https://shri.ink/api/check-url

Request Body

{
  "url": "https://example.com/long-url"  // Required
}

Response

{
  "success": true,
  "data": {
    "url": "https://example.com/long-url",
    "status": 200,
    "ok": true,
    "redirected": false,
    "redirectUrl": null
  }
}