SDKs overview
Software Development Kits (SDKs) and client libraries provide a layer of abstraction over raw API requests, simplifying the integration of a service into an application. For the 1pt URL shortening service, developers interact with a RESTful API to create, manage, and retrieve information about short URLs. The 1pt API is designed to be straightforward, utilizing standard HTTP methods and JSON for data exchange, as detailed in the 1pt API documentation.
While 1pt primarily provides cURL examples in its official documentation, the simplicity of its API structure allows for the easy development of custom client libraries in virtually any programming language. These libraries typically handle the construction of API requests, management of API keys for authentication, and parsing of JSON responses, reducing boilerplate code for developers. The core functionality accessible via the API includes creating new short links, specifying custom short URLs, and retrieving basic analytics for existing links. Implementing a client library involves understanding HTTP request methods (GET, POST), header manipulation for API key inclusion, and JSON serialization/deserialization. Developers can also refer to general principles of making web requests with the Fetch API for client-side JavaScript or similar HTTP client libraries in other languages.
Official SDKs by language
As of 2026-05-29, 1pt does not officially publish dedicated SDKs or client libraries for specific programming languages. The 1pt API reference provides direct cURL examples for interacting with its endpoints. This approach requires developers to implement HTTP requests and JSON parsing directly within their applications, or to build their own client wrappers. The API is designed with simplicity in mind, making it accessible for direct integration using standard HTTP client libraries available in most programming languages.
The primary method for interacting with the 1pt API, as demonstrated in their documentation, involves sending HTTP POST requests to the /api/v1/add endpoint for URL shortening, and GET requests for retrieving link information. Authentication is handled by including an API key in the request headers or as a query parameter. This direct API interaction model is common for services with lightweight APIs, allowing for maximum flexibility in implementation across different technology stacks.
While there are no official SDKs, the following table illustrates how a developer might conceptualize such tools if they were to exist or be created by the community. The 'Install Command' column indicates typical package manager commands for hypothetical libraries, and 'Maturity' refers to a general assessment of stability and feature completeness.
| Language | Package Name (Hypothetical) | Install Command (Hypothetical) | Maturity (Hypothetical) |
|---|---|---|---|
| Python | 1pt-python |
pip install 1pt-python |
Community-driven |
| Node.js | @1pt/client |
npm install @1pt/client |
Community-driven |
| PHP | 1pt/php-client |
composer require 1pt/php-client |
Community-driven |
| Go | github.com/user/go-1pt |
go get github.com/user/go-1pt |
Community-driven |
| Ruby | 1pt-ruby |
gem install 1pt-ruby |
Community-driven |
Installation
Since 1pt does not provide official SDKs, installation primarily involves setting up an HTTP client library in your chosen programming language. These libraries are standard tools for making web requests and parsing responses.
General Steps for Direct API Integration:
- Obtain an API Key: Register on the 1pt website and locate your API key, typically found in your account settings or dashboard. This key is crucial for authenticating your API requests.
- Choose an HTTP Client Library: Select a suitable HTTP client library for your programming language. Examples include:
- Python:
requests(PyPI requests package) - Node.js:
axios(npm axios package) or the built-infetchAPI - PHP: Guzzle HTTP Client (Guzzle documentation)
- Go: Standard library
net/http - Ruby:
httparty(HTTParty GitHub repository) or standard librarynet/http - Install the Library: Use your language's package manager to install the chosen HTTP client.
- Python:
pip install requests - Node.js:
npm install axios - PHP:
composer require guzzlehttp/guzzle - Go:
go get github.com/go-resty/resty/v2(example with Resty, a popular Go HTTP client) - Ruby:
gem install httparty - Implement Request Logic: Write code to construct HTTP requests, include your API key, send the request to the 1pt API endpoint (
https://1pt.co/api/v1/addfor shortening), and process the JSON response.
For detailed API endpoint specifications, including required parameters and expected response formats, refer to the official 1pt API documentation.
Quickstart example
The following example demonstrates how to shorten a URL using the 1pt API with Python's requests library. This approach mirrors the direct API interaction model encouraged by 1pt's documentation.
Python Example (using requests)
First, ensure you have the requests library installed:
pip install requests
Then, use the following Python code:
import requests
import json
# Replace with your actual 1pt API Key
API_KEY = "YOUR_1PT_API_KEY"
# The URL you want to shorten
LONG_URL = "https://www.example.com/very/long/url/that/needs/shortening"
# The 1pt API endpoint for adding a new link
API_ENDPOINT = "https://1pt.co/api/v1/add"
# Prepare the request headers with the API key
headers = {
"Content-Type": "application/json",
"X-Api-Key": API_KEY # Or include in JSON payload if specified by 1pt docs
}
# Prepare the request payload
data = {
"long": LONG_URL
# Add other parameters like "short" for custom short links if needed
# "short": "mycustomlink"
}
try:
# Send the POST request to the 1pt API
response = requests.post(API_ENDPOINT, headers=headers, data=json.dumps(data))
response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
# Parse the JSON response
result = response.json()
if result.get("status") == 200:
short_url = result.get("short")
print(f"Successfully shortened URL: {LONG_URL}")
print(f"Short URL: {short_url}")
print(f"Full API Response: {json.dumps(result, indent=2)}")
else:
print(f"Error shortening URL: {result.get('message', 'Unknown error')}")
print(f"Full API Response: {json.dumps(result, indent=2)}")
except requests.exceptions.RequestException as e:
print(f"Network or HTTP error occurred: {e}")
except json.JSONDecodeError:
print(f"Failed to decode JSON response: {response.text}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
This example demonstrates how to send a POST request with the long URL in the JSON body and the API key in the X-Api-Key header. The response is then parsed to extract the shortened URL. Always ensure your API key is kept secure and not exposed in client-side code or public repositories.
Community libraries
Given that 1pt does not provide official SDKs, the development of client libraries often falls to the community. These libraries are typically open-source projects hosted on platforms like GitHub and distributed via language-specific package managers (e.g., npm for Node.js, PyPI for Python, Composer for PHP). Community-contributed libraries can vary in terms of completeness, maintenance, and adherence to best practices.
When considering a community library, it is advisable to evaluate the following:
- Activity: Check the project's commit history, issue tracker, and pull request activity to gauge ongoing maintenance.
- Documentation: Look for clear and comprehensive documentation, including installation instructions, usage examples, and API coverage.
- Test Coverage: A robust test suite indicates reliability and helps ensure the library functions as expected.
- Community Support: Active community discussion forums or issue trackers can be valuable for troubleshooting and getting assistance.
- License: Understand the licensing terms to ensure compatibility with your project's requirements.
While specific community libraries are not listed here due to their dynamic nature and the need for constant verification, developers can often find such projects by searching package repositories or GitHub for terms like "1pt client," "1pt SDK," or "1pt API wrapper" combined with their desired programming language. Always prioritize libraries that are well-documented, actively maintained, and have a clear history of contributions.