SDKs and HTTP clients
There is no official LinkLane SDK package yet. The API is plain JSON over HTTPS, so any HTTP client works. The small clients below handle the key, JSON and errors for you. Copy one into your project.
JavaScript
Works in Node.js 18+ and other runtimes with fetch. Keep it on your server: never ship an API key to a browser.
linklane.js
const BASE = "https://api.linklane.io/api";
export class LinkLaneError extends Error {
constructor(status, detail) {
super(typeof detail === "string" ? detail : JSON.stringify(detail));
this.status = status;
this.detail = detail;
}
}
export async function linklane(method, path, body) {
const res = await fetch(BASE + path, {
method,
headers: {
Authorization: `Bearer ${process.env.LINKLANE_API_KEY}`,
...(body && { "Content-Type": "application/json" }),
},
body: body && JSON.stringify(body),
});
const data = res.status === 204 ? null : await res.json();
if (!res.ok) throw new LinkLaneError(res.status, data?.detail);
return data;
}
Use it
import { linklane } from "./linklane.js";
const link = await linklane("POST", "/links", { url: "https://example.com", tags: ["docs"] });
const stats = await linklane("GET", `/links/${link.id}/analytics?days=7`);
await linklane("PATCH", `/links/${link.id}`, { archived: true });
Python
Uses requests.
linklane.py
import os
import requests
BASE = "https://api.linklane.io/api"
_session = requests.Session()
_session.headers["Authorization"] = f"Bearer {os.environ['LINKLANE_API_KEY']}"
class LinkLaneError(Exception):
def __init__(self, status, detail):
super().__init__(detail)
self.status = status
self.detail = detail
def linklane(method, path, body=None, **params):
res = _session.request(method, BASE + path, json=body, params=params or None)
data = res.json() if res.content else None
if not res.ok:
raise LinkLaneError(res.status_code, (data or {}).get("detail"))
return data
Use it
from linklane import linklane
link = linklane("POST", "/links", {"url": "https://example.com", "tags": ["docs"]})
stats = linklane("GET", f"/links/{link['id']}/analytics", days=7)
linklane("PATCH", f"/links/{link['id']}", {"archived": True})