Getting started overview
This guide provides a rapid pathway to initiating development with Shrtlnk. It covers the essential steps from account creation and API key retrieval to executing your first successful API request. The Shrtlnk API enables programmatic URL shortening, custom link creation, and access to link analytics, supporting applications requiring efficient link management Shrtlnk API documentation. Developers can integrate Shrtlnk into various workflows for tasks such as marketing campaign tracking, content sharing, and backend automation.
The following table outlines the foundational steps:
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Create a new Shrtlnk account. | Shrtlnk homepage |
| 2. Get API Key | Locate and copy your personal API key. | Shrtlnk Dashboard > Settings |
| 3. Make Request | Send a POST request to shorten a URL. |
Your development environment (e.g., cURL, Python) |
| 4. Confirm Link | Verify the short link was created and resolves correctly. | Shrtlnk Dashboard > Links, or browser test |
Create an account and get keys
-
Register for a Shrtlnk Account: Navigate to the Shrtlnk homepage and complete the sign-up process. Shrtlnk offers a free tier which includes 1,000 links per month and 10,000 clicks per month, suitable for initial testing and small-scale use Shrtlnk pricing plans.
-
Access Your Dashboard: After successful registration and login, you will be redirected to your Shrtlnk dashboard.
-
Retrieve Your API Key:
- From the dashboard, locate and click on the 'Settings' or 'API' section. The exact navigation may vary slightly but is typically found in the main navigation or user profile menu.
- Within the settings, you should find a dedicated section for 'API Keys' or 'Developer Settings'. Your personal API key will be displayed here.
- Copy this API key securely. It acts as a bearer token for authenticating your API requests. Keep it confidential, as unauthorized access to your key can compromise your Shrtlnk account.
The API key is a unique identifier that authenticates your application when interacting with the Shrtlnk API, similar to how Stripe API keys or Google Maps Platform API keys function to control access and track usage.
Your first request
With your API key in hand, you can now make your first request to the Shrtlnk API. This example demonstrates how to create a new short URL using cURL. The Shrtlnk API is RESTful, so requests are typically made using standard HTTP methods like POST for creation Shrtlnk API reference.
API Endpoint
The base URL for the API is https://api.shrtlnk.dev/client/v1.
Authentication
API key authentication is performed by including your API key in the Authorization header as a Bearer token.
Example 1: Create a Short Link with cURL
This POST request will shorten a long URL, returning a Shrtlnk-generated short URL.
curl -X POST \
https://api.shrtlnk.dev/client/v1/links \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{"url": "https://www.apispine.com/example-long-url-for-testing-shrtlnk-integration", "permanent": false}'
Replace YOUR_API_KEY with the actual API key you retrieved from your Shrtlnk dashboard. The url field in the JSON body should contain the full URL you wish to shorten. The permanent field indicates if the link should be persistent; setting it to false is suitable for temporary test links.
Expected Response (201 Created)
A successful request will return a 201 Created HTTP status code and a JSON object containing details of the newly created short link:
{
"message": "Link created successfully.",
"data": {
"id": "clw0x7a7d001608jv2ghqg01t",
"user_id": "clw0x7a7d000008jv2ghqg01t",
"url": "https://www.apispine.com/example-long-url-for-testing-shrtlnk-integration",
"shrtlnk": "https://shrtlnk.dev/st/example",
"clicks": 0,
"permanent": false,
"created_at": "2026-05-29T10:00:00.000000Z",
"updated_at": "2026-05-29T10:00:00.000000Z"
}
}
The shrtlnk field in the response contains the newly generated short URL. You can test this URL in a web browser to ensure it redirects correctly to your original long URL.
Example 2: Create a Short Link with Python
For Python developers, the requests library provides a straightforward way to interact with RESTful APIs:
import requests
import json
api_key = "YOUR_API_KEY"
long_url = "https://www.apispine.com/another-example-for-python-testing"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {api_key}"
}
payload = {
"url": long_url,
"permanent": False
}
response = requests.post("https://api.shrtlnk.dev/client/v1/links", headers=headers, data=json.dumps(payload))
if response.status_code == 201:
print("Short link created successfully!")
print("Response:", response.json())
short_link = response.json()["data"]["shrtlnk"]
print(f"Generated short link: {short_link}")
else:
print(f"Error creating short link: {response.status_code}")
print("Response:", response.text)
Remember to replace YOUR_API_KEY with your actual Shrtlnk API key. This script sends a JSON payload to the Shrtlnk API and prints the resulting short link or any error messages.
Common next steps
After successfully creating your first short URL, consider exploring these additional Shrtlnk API functionalities:
-
Custom Short Links: Instead of letting Shrtlnk generate a random short code, you can specify a custom slug for your link. This is useful for branding or creating memorable URLs. Refer to the Shrtlnk API documentation for custom links.
-
Link Analytics: Shrtlnk provides an API to retrieve click data and other analytics for your shortened URLs. This allows you to integrate link performance tracking directly into your applications.
-
QR Code Generation: For each shortened link, Shrtlnk can generate a corresponding QR code, which can be useful for print media or in-person promotions. The API supports programmatic access to these QR codes.
-
Link Management: Explore endpoints for listing, updating, and deleting existing short links. This enables full lifecycle management of your URLs through your application.
-
Error Handling: Implement robust error handling in your application to manage various HTTP status codes and error messages returned by the Shrtlnk API. Understanding common HTTP status codes, such as
400 Bad Requestfor invalid input or401 Unauthorizedfor missing/invalid API keys, is crucial for building reliable integrations MDN HTTP Status Codes reference. -
SDKs and Libraries: While Shrtlnk does not officially provide client SDKs, community-contributed libraries might exist for popular programming languages. Alternatively, constructing requests directly using HTTP clients (like Python's
requestsor Node.js'saxios) is a common and effective approach for RESTful APIs.
Troubleshooting the first call
If your initial API call to Shrtlnk does not succeed, consider the following common issues:
-
Invalid API Key: Double-check that your API key is correctly copied and pasted into the
Authorization: Bearer YOUR_API_KEYheader. Even minor typos or extra spaces can invalidate the key. Regenerating the key in your dashboard might resolve issues if you suspect it's compromised or corrupted. -
Missing or Incorrect Headers: Ensure you are sending the required
Content-Type: application/jsonandAccept: application/jsonheaders, as specified in the examples. These inform the API about the format of your request body and your preferred response format. -
Malformed JSON Body: Verify that the JSON payload in your
-d(cURL) ordata(Python requests) argument is syntactically correct. Unmatched braces, missing commas, or incorrect value types (e.g., booleanfalsevs. string"false") can lead to400 Bad Requesterrors. Online JSON validators can help identify issues. -
Incorrect Endpoint: Confirm that the URL you are sending the request to is
https://api.shrtlnk.dev/client/v1/links. Using an incorrect path or HTTP method (e.g.,GETinstead ofPOSTfor creating a link) will result in errors. -
Network Issues: Temporarily disable any VPNs or firewalls that might be blocking outbound HTTP requests from your development environment. Ensure you have a stable internet connection.
-
Rate Limiting: While unlikely for a first request, keep in mind that APIs often implement rate limits to prevent abuse. If you are sending many requests rapidly, you might encounter
429 Too Many Requestserrors. Refer to the Shrtlnk documentation for specific rate limit details. -
Check Error Messages: The Shrtlnk API typically provides descriptive error messages in the JSON response body. Examine these messages carefully as they often pinpoint the exact cause of the problem.