Getting started overview

To begin using Short Link, the primary steps include creating an account, establishing a branded domain if required, and generating an API key for authentication. Once configured, developers can integrate Short Link's capabilities into their applications to programmatically create, manage, and track shortened URLs. The API supports various programming languages and offers endpoints for link creation, retrieval, updating, and deletion, alongside analytics access for performance monitoring.

Before proceeding, ensure you have access to a web browser for account setup and a development environment capable of making HTTP requests, such as cURL, Python with requests, or JavaScript with fetch. The Short Link API requires an API key in the request header for authentication, as detailed in the Short Link API documentation.

Step What to do Where
1. Sign up Create a Short Link account. short.io homepage
2. Get API Key Locate and copy your API key from the dashboard. Short Link dashboard settings
3. Make Request Construct and execute an API call to shorten a URL. Your development environment

Create an account and get keys

Access to the Short Link API requires an active account and a corresponding API key. Short Link offers a free tier accommodating up to 500 short links and 1000 tracked clicks per month, which is suitable for initial testing and small-scale projects. For higher limits or additional features such as custom branded domains, various Short Link paid plans are available, starting with the Personal plan.

Account creation

  1. Navigate to the Short Link homepage.
  2. Click on the "Sign up" or "Get Started Free" button.
  3. Provide your email address and create a password, or sign up using a Google or Apple account.
  4. Follow any on-screen prompts to complete the account setup, which may include verifying your email address.

Locate your API key

After successfully creating and logging into your Short Link account, your API key can be found within the dashboard settings. This key authenticates your API requests.

  1. Log in to your Short Link account.
  2. In the dashboard navigation pane, locate and click on "Integrations" or "API Keys" (the exact label may vary slightly in future updates but will be in a similar section, per Short Link's API blog category).
  3. Your API key will be displayed. Copy this key securely. It is a sensitive credential and should be treated like a password.

For security, API keys should be stored securely and not hardcoded directly into client-side applications. Best practices for API key management include using environment variables or dedicated secret management services, as recommended by general security guidelines like those from Google Cloud's API key security documentation.

Your first request

With your API key in hand, you can now make your first request to the Short Link API. This example demonstrates shortening a URL using the /links endpoint. The API accepts POST requests with a JSON body specifying the long URL and optionally a domain and path for the shortened link.

API endpoint and method

  • Endpoint: https://api.short.io/links
  • Method: POST
  • Authentication: Authorization: Bearer YOUR_API_KEY header
  • Content-Type: application/json header

Example: Shorten a URL using cURL

cURL is a widely available command-line tool for making network requests and is useful for initial API testing.

curl -X POST \ 
  https://api.short.io/links \ 
  -H 'Content-Type: application/json' \ 
  -H 'Authorization: Bearer YOUR_API_KEY' \ 
  -d '{ 
    "originalURL": "https://www.example.com/very/long/url/that/needs/shortening", 
    "domain": "YOUR_BRANDED_DOMAIN.com" 
  }'

Replace YOUR_API_KEY with the key you obtained from your dashboard. If you do not have a custom branded domain, you can omit the "domain": "YOUR_BRANDED_DOMAIN.com" line, and Short Link will use a default domain.

Example: Shorten a URL using Python

Using the requests library in Python:

import requests
import json

api_key = "YOUR_API_KEY"
original_url = "https://www.example.com/another/long/url/for/shortening"
domain = "YOUR_BRANDED_DOMAIN.com" # Optional: remove if not using a custom domain

url = "https://api.short.io/links"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {api_key}"
}
payload = {
    "originalURL": original_url,
    "domain": domain
}

response = requests.post(url, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print("Short link created successfully!")
    print(response.json())
else:
    print(f"Error: {response.status_code}")
    print(response.json())

Remember to replace YOUR_API_KEY and potentially YOUR_BRANDED_DOMAIN.com with your actual values.

Expected response

A successful request will return a 200 OK status code and a JSON object containing details of the newly created short link, similar to this structure:

{
  "shortURL": "https://yourdomain.com/shortlink",
  "originalURL": "https://www.example.com/very/long/url/that/needs/shortening",
  "id": "someLinkID",
  "owner_id": "someUserID",
  "domain_id": "someDomainID",
  "path": "shortlink",
  "secure": true,
  "createdAt": "2023-01-01T12:00:00.000Z",
  "updatedAt": "2023-01-01T12:00:00.000Z"
}

Common next steps

After successfully creating your first short link, consider these common next steps to further utilize the Short Link API:

  • Explore other API endpoints: The Short Link API documentation details endpoints for managing existing links (e.g., retrieving, updating, deleting), retrieving analytics data for your short links, and managing domains.
  • Integrate with a branded domain: If you plan to use branded short links (e.g., yourbrand.com/link), configure your custom domain within the Short Link dashboard and ensure it's used in your API requests.
  • Implement webhooks: For real-time notifications about link events (e.g., new clicks), Short Link supports webhooks. Configure them in your dashboard to send data to your application's endpoint. Guidance on securing webhooks is available from sources like Stripe's webhook security documentation.
  • Monitor analytics: Leverage the analytics endpoints to programmatically track clicks, referrers, and audience demographics for your shortened URLs, feeding this data into your analytics dashboards or reporting tools.
  • Error handling: Implement robust error handling in your application to gracefully manage scenarios such as invalid API keys, malformed requests, or rate limiting responses from the API.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting steps:

  • Check API Key: Double-check that your API key is correct and included in the Authorization: Bearer YOUR_API_KEY header. An incorrect or missing key will result in a 401 Unauthorized error.
  • Content-Type Header: Ensure the Content-Type: application/json header is present if you are sending a JSON payload. Missing or incorrect content types can lead to 400 Bad Request errors.
  • JSON Body Syntax: Verify that your JSON request body is correctly formatted. Syntax errors, missing commas, or unescaped characters can cause parsing failures. Use a JSON linter if unsure.
  • Required Parameters: Confirm that all mandatory parameters, such as originalURL, are included in your request body. Refer to the Short Link API reference for required fields per endpoint.
  • Domain Ownership: If you are specifying a custom domain in your request, ensure that the domain is correctly added and configured in your Short Link dashboard and that your account has permission to use it.
  • Network Connectivity: Confirm that your development environment has internet access and is not blocked by a firewall from reaching api.short.io.
  • API Status Page: Check Short Link's official status page (if available, often linked from their documentation) for any ongoing service disruptions or outages.
  • Review Error Messages: The API usually returns descriptive error messages in the response body if a request fails. Read these messages carefully, as they often pinpoint the exact issue.