SDKs overview
Shrtlnk provides Software Development Kits (SDKs) and client libraries to facilitate integration with its URL shortening and management platform. These tools abstract the underlying RESTful API, allowing developers to interact with Shrtlnk services using familiar programming language constructs rather than direct HTTP requests. The official documentation offers code examples across multiple languages, illustrating common API operations such as creating, retrieving, updating, and deleting short links.
The Shrtlnk API is designed to be straightforward, with authentication managed via an API key, as detailed in the Shrtlnk API reference documentation. This approach aligns with common practices for secure API access, where an API key serves as a token passed with each request to authenticate the caller, a method often seen in cloud services like AWS API interactions.
Developers can utilize these SDKs to automate tasks like generating short URLs, customizing back-halves, tracking click analytics, and managing link metadata programmatically. The availability of examples in various languages aims to support a broad developer base, reducing the typical overhead of parsing API specifications and constructing HTTP requests manually.
Official SDKs by language
Shrtlnk officially supports several programming languages through code examples and, in some cases, dedicated client libraries. While not all languages have a traditionally packaged 'SDK' in the sense of a comprehensive, versioned library, Shrtlnk provides direct code snippets and guidance to interact with its API effectively. The primary languages for which examples are provided include Python, Node.js, Go, PHP, and Ruby.
| Language | Documentation Status | Installation Method | Maturity |
|---|---|---|---|
| Python | Code examples available via Shrtlnk's Python API examples | No dedicated package; use standard HTTP libraries (e.g., requests) |
Stable (API examples) |
| Node.js | Code examples available via Shrtlnk's Node.js API examples | No dedicated package; use standard HTTP libraries (e.g., axios, node-fetch) |
Stable (API examples) |
| Go | Code examples available via Shrtlnk's Go API examples | No dedicated package; use standard HTTP libraries (e.g., net/http) |
Stable (API examples) |
| PHP | Code examples available via Shrtlnk's PHP API examples | No dedicated package; use standard HTTP libraries (e.g., cURL extension, Guzzle) |
Stable (API examples) |
| Ruby | Code examples available via Shrtlnk's Ruby API examples | No dedicated package; use standard HTTP libraries (e.g., Net::HTTP) |
Stable (API examples) |
| cURL | Direct command examples available via Shrtlnk's cURL API examples | Pre-installed on most *nix systems | Standard utility |
The distinction between a full SDK and comprehensive code examples is important. While Shrtlnk provides robust examples that demonstrate API usage patterns, developers are generally expected to incorporate these snippets into their projects using their language's native HTTP client libraries. For instance, a Python developer might use the popular requests library for HTTP calls, as illustrated in many HTTP status code guides.
Installation
Since Shrtlnk's official support primarily involves code examples rather than installable packages, direct installation of a dedicated Shrtlnk SDK is not typically required. Instead, developers will install and utilize their language's standard HTTP client libraries. The following provides general installation instructions for common HTTP clients in the listed languages:
Python
For Python, the requests library is a widely used HTTP client. Install it via pip:
pip install requests
Node.js
For Node.js, axios or node-fetch are common choices for making HTTP requests. Install one using npm:
npm install axios
# or
npm install node-fetch
Go
Go uses its built-in net/http package, which does not require external installation:
import (
"net/http"
)
PHP
For PHP, you can use the built-in cURL extension or a third-party library like Guzzle:
To ensure cURL is enabled in your PHP installation, check your php.ini configuration. For Guzzle, install via Composer:
composer require guzzlehttp/guzzle
Ruby
Ruby typically uses its built-in Net::HTTP library, which requires no external installation:
require 'net/http'
require 'uri'
Quickstart example
The following Python example demonstrates how to create a new short link using the Shrtlnk API. This example assumes you have an API key and the requests library installed.
import requests
import json
# Replace with your actual Shrtlnk API Key
API_KEY = "YOUR_SHRTLNK_API_KEY"
BASE_URL = "https://api.shrtlnk.dev/v1/link"
def create_shrtlnk(long_url, custom_key=None, tags=None):
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-Api-Key": API_KEY
}
payload = {
"url": long_url
}
if custom_key:
payload["key"] = custom_key
if tags:
payload["tags"] = tags
try:
response = requests.post(BASE_URL, headers=headers, data=json.dumps(payload))
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
return response.json()
except requests.exceptions.HTTPError as http_err:
print(f"HTTP error occurred: {http_err} - {response.text}")
except Exception as err:
print(f"An error occurred: {err}")
return None
# Example Usage:
# Create a simple short link
link_data = create_shrtlnk("https://www.apispine.com/shrtlnk-profile")
if link_data:
print(f"Short URL: {link_data.get('shrtlnk')}")
print(f"Original URL: {link_data.get('url')}")
# Create a short link with a custom key and tags
link_data_custom = create_shrtlnk(
"https://docs.shrtlnk.dev/",
custom_key="apispine-docs",
tags=["documentation", "api"]
)
if link_data_custom:
print(f"Custom Short URL: {link_data_custom.get('shrtlnk')}")
print(f"Original URL: {link_data_custom.get('url')}")
This Python snippet initializes with your API key, constructs the necessary headers and payload for a POST request, and then sends it to the Shrtlnk API endpoint. Error handling is included to catch potential issues with the HTTP request or API response. Successful responses return a JSON object containing the newly created short link and other relevant details, as outlined in the Shrtlnk API documentation.
Community libraries
As of May 2026, the Shrtlnk ecosystem is primarily supported by official code examples for direct API interaction rather than a broad suite of community-maintained, language-specific SDKs. This approach is common for APIs that prioritize direct HTTP interaction and provide comprehensive documentation and examples. Developers often create their own client wrappers or integrate the provided examples into their existing codebases.
For services like Shrtlnk, where an official SDK might not be available for every niche language or framework, developers often resort to creating custom HTTP clients. This can involve using generic HTTP client libraries (e.g., requests in Python, axios in Node.js) to construct requests according to the API's specification. The Open API Initiative's OpenAPI Specification can also aid in generating client code from an API definition, though Shrtlnk's API reference does not explicitly state an OpenAPI definition file being available for direct client generation. In the absence of official client libraries, community contributions typically emerge as projects on platforms like GitHub, often starting as simple wrappers around the official API endpoints for a specific language or framework. These contributions can vary in maturity and support, so it is advisable to review their maintenance status and community activity if choosing to use a third-party library.