SDKs overview
Clico provides software development kits (SDKs) to facilitate programmatic interaction with its URL shortening and link management platform. These SDKs abstract the underlying RESTful API, allowing developers to integrate Clico's functionalities into their applications using native language constructs rather than direct HTTP requests. The primary SDK available targets Node.js environments, addressing the needs of JavaScript developers for server-side and client-side (via bundlers) applications. The SDK aims to simplify tasks such as creating short URLs, managing custom domains, and retrieving link analytics data programmatically.
Integrating with an SDK can reduce development time by handling authentication, request formatting, and response parsing, which are common complexities when working directly with an HTTP API. Clico's approach is consistent with common practices in API development, where SDKs are offered to enhance developer experience and accelerate adoption by providing pre-built components for common operations. The official documentation details the methods and parameters available through the SDKs, ensuring developers can leverage the full range of Clico's API capabilities effectively.
Official SDKs by language
Clico maintains an official SDK primarily for Node.js, which is designed to provide a robust and well-documented interface for JavaScript developers. This SDK is regularly updated to reflect the latest API features and improvements, ensuring compatibility and access to new functionalities as they become available on the Clico platform. The official Node.js SDK covers core functionalities such as URL shortening, managing custom domains, and accessing detailed link analytics. It is distributed through standard package managers, simplifying its inclusion in development projects.
For languages without an official SDK, developers can interact with the Clico platform directly via its Clico REST API reference. The API is designed with standard HTTP methods and JSON payloads, making it accessible from any programming language capable of making HTTP requests. This direct API access allows for maximum flexibility, although it requires developers to manage aspects like authentication and error handling themselves.
Official SDKs table
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| Node.js | @clico/sdk |
npm install @clico/sdk or yarn add @clico/sdk |
Stable |
The Node.js SDK is actively maintained by Clico, ensuring it aligns with the latest API versions and best practices for JavaScript development. This commitment helps developers build reliable integrations without needing to constantly monitor API changes manually. For comprehensive details on each SDK's functionalities and available methods, developers can refer to the Clico developer documentation.
Installation
Installing the Clico Node.js SDK involves using a package manager commonly employed in JavaScript development. The process is straightforward and typically completed with a single command. Before installation, ensure you have Node.js and npm (Node Package Manager) or Yarn installed on your development environment. Node.js is a runtime environment that executes JavaScript code outside a web browser, and npm is its default package manager; Yarn is an alternative package manager. For instructions on installing Node.js, refer to the Node.js npm getting started guide.
Node.js SDK installation
To install the official Node.js SDK, navigate to your project's root directory in your terminal and execute one of the following commands:
Using npm:
npm install @clico/sdk
Using Yarn:
yarn add @clico/sdk
These commands download the @clico/sdk package and its dependencies from the npm registry and add them to your project's node_modules directory, updating your package.json and package-lock.json (or yarn.lock) files accordingly. After installation, the SDK is available for import into your JavaScript or TypeScript files.
Quickstart example
This quickstart example demonstrates how to initialize the Clico Node.js SDK and create a new shortened URL. Before running the example, ensure you have installed the @clico/sdk package as described in the Installation section and have obtained your Clico API key from your Clico account dashboard. API keys are essential for authenticating your requests and accessing Clico's services.
Node.js quickstart: Create a short URL
The following JavaScript code snippet illustrates the basic steps to import the SDK, configure it with your API key, and make a call to shorten a long URL. Error handling is included to demonstrate how to catch and process potential issues during the API call.
const Clico = require('@clico/sdk');
const clico = new Clico('YOUR_API_KEY'); // Replace with your actual Clico API Key
async function createShortUrl() {
try {
const longUrl = 'https://www.example.com/very/long/url/that/needs/shortening/for/sharing';
const customAlias = 'my-custom-link'; // Optional: specify a custom alias
const { data } = await clico.links.create({
long_url: longUrl,
alias: customAlias // Only include if you want a custom alias
});
console.log('Short URL created successfully:');
console.log('Short URL:', data.short_url);
console.log('Original URL:', data.long_url);
console.log('Alias (if provided):', data.alias);
console.log('Clicks:', data.clicks);
} catch (error) {
console.error('Error creating short URL:');
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error('Status:', error.response.status);
console.error('Data:', error.response.data);
console.error('Headers:', error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.error('Request:', error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.error('Message:', error.message);
}
console.error('Config:', error.config);
}
}
createShortUrl();
This example initializes the Clico client with an API key. It then calls the links.create method with a long_url and an optional alias. Upon successful creation, the response containing the new short URL and other link details is logged. In case of an error, the catch block logs detailed error information, which can be useful for debugging. For more advanced features, such as adding tags, setting expiration dates, or retrieving analytics, consult the Clico API reference documentation.
Community libraries
While Clico officially supports a Node.js SDK, the open nature of its REST API allows developers to create and maintain community-contributed libraries in various other programming languages. These community libraries can offer idiomatic wrappers for languages not covered by official SDKs, potentially accelerating integration for developers working in environments like Python, Ruby, Go, or PHP. The development and maintenance of these libraries are driven by the community, often hosted on platforms such as GitHub.
Community libraries can vary in their completeness, maintenance status, and adherence to the latest API features. Developers considering using a community-developed SDK should evaluate its documentation, recent commit history, issue tracker, and community engagement to assess its suitability for their projects. It is also advisable to review the source code for security practices and compatibility with the Clico API specification. Search popular code repositories like GitHub for clico api client or clico sdk in your preferred language to discover available options.
Developers contributing to or creating community libraries play a vital role in expanding the accessibility of Clico's API to a broader ecosystem of programming languages and frameworks. Such contributions enable developers to integrate Clico's link management features into diverse application architectures, from web services to mobile backends, leveraging their existing technology stacks. For general guidance on integrating with REST APIs, resources such as the MDN Web Docs on REST provide foundational knowledge applicable to direct API interactions.