SnipyDevelopers
SDKs & Libraries

SDKs & Libraries

Integrate with the Snipy API using your preferred language. Below you will find ready-to-use code examples and wrapper patterns for the most common operations.

Official SDKs coming soon

We are actively developing official SDK packages for Node.js (npm) and Python (pip). In the meantime, use the patterns below as a foundation for your own wrapper. The API follows REST conventions and is straightforward to integrate with any HTTP client.

Available examples

JavaScript / TypeScript
Works with Node.js, Deno, Bun, and browser environments using the Fetch API.
Python
Uses the popular requests library. Compatible with Python 3.8+.
cURL
Command-line examples for testing and scripting. Works on macOS, Linux, and Windows.

JavaScript / TypeScript

A minimal API client wrapper that handles authentication, error handling, and typed responses.

snipy-client.ts
const BASE_URL = "https://api.snipy.com";

interface SnipyResponse<T = unknown> {
  error: 0 | 1;
  data?: T;
  message?: string;
}

interface SnipyListResponse<K extends string, T> {
  error: 0;
  data: {
    result: number;
    perpage: number;
    currentpage: number;
    nextpage: number | null;
    maxpage: number;
  } & Record<K, T[]>;
}

class SnipyClient {
  private token: string;

  constructor(token: string) {
    this.token = token;
  }

  private async request<T>(
    method: string,
    path: string,
    body?: unknown
  ): Promise<T> {
    const res = await fetch(`${BASE_URL}${path}`, {
      method,
      headers: {
        "Authorization": `Bearer ${this.token}`,
        "Content-Type": "application/json",
      },
      body: body ? JSON.stringify(body) : undefined,
    });

    const json = await res.json();

    if (json.error === 1) {
      throw new Error(json.message || "API Error");
    }

    return json as T;
  }

  // Links
  async listLinks(page = 1, limit = 15) {
    return this.request<SnipyListResponse<"urls", Link>>(
      "GET", `/api/urls?page=${page}&limit=${limit}`
    );
  }

  async createLink(options: CreateLinkOptions) {
    return this.request<SnipyResponse<Link>>(
      "POST", "/api/url/add", options
    );
  }

  async getLink(id: number) {
    return this.request<SnipyResponse<Link>>(
      "GET", `/api/url/${id}`
    );
  }

  async updateLink(id: number, data: Partial<CreateLinkOptions>) {
    return this.request<SnipyResponse<Link>>(
      "PUT", `/api/url/${id}/update`, data
    );
  }

  async deleteLink(id: number) {
    return this.request<SnipyResponse>(
      "DELETE", `/api/url/${id}/delete`
    );
  }

  // QR Codes
  async listQRs(page = 1) {
    return this.request<SnipyListResponse<"qrs", QR>>(
      "GET", `/api/qrs?page=${page}`
    );
  }

  async createQR(options: CreateQROptions) {
    return this.request<SnipyResponse<QR>>(
      "POST", "/api/qr/add", options
    );
  }

  async downloadQR(id: number, format: "png" | "svg" | "pdf", size = 300) {
    const res = await fetch(
      `${BASE_URL}/api/qr/${id}/download?format=${format}&size=${size}`,
      { headers: { "Authorization": `Bearer ${this.token}` } }
    );
    return res.arrayBuffer();
  }

  // Stats
  async getLinkStats(id: number, from?: string, to?: string) {
    const params = new URLSearchParams();
    if (from) params.set("from", from);
    if (to) params.set("to", to);
    const qs = params.toString() ? `?${params}` : "";
    return this.request<SnipyResponse>(
      "GET", `/api/url/${id}/stats${qs}`
    );
  }

  // Account
  async getAccount() {
    return this.request<SnipyResponse>("GET", "/api/account");
  }
}

// Types
interface Link {
  id: number;
  alias: string;
  shorturl: string;
  longurl: string;
  clicks: number;
  domain: string;
  date: string;
}

interface CreateLinkOptions {
  url: string;
  alias?: string;
  domain?: string;
  password?: string;
  expiry?: string;
  maxClicks?: number;
  campaignId?: number;
}

interface QR {
  id: number;
  name: string;
  url: string;
  scans: number;
  date: string;
}

interface CreateQROptions {
  name: string;
  url: string;
  foreground?: string;
  background?: string;
  size?: number;
  errorCorrection?: "L" | "M" | "Q" | "H";
}

export { SnipyClient };
Usage example
import { SnipyClient } from "./snipy-client";

const snipy = new SnipyClient("YOUR_TOKEN");

// Create a short link
const { data: link } = await snipy.createLink({
  url: "https://example.com/page",
  alias: "my-link",
  domain: "snipy.to",
});

console.log("Created:", link.shorturl);

// Get click stats
const { data: stats } = await snipy.getLinkStats(link.id);
console.log("Total clicks:", stats.totalClicks);

// List all links
const { data } = await snipy.listLinks(1, 25);
console.log(`Page 1 of ${data.maxpage}, ${data.result} total links`);

Python

A clean Python wrapper using the requests library.

snipy_client.py
import requests
from typing import Optional


class SnipyClient:
    BASE_URL = "https://api.snipy.com"

    def __init__(self, token: str):
        self.session = requests.Session()
        self.session.headers.update({
            "Authorization": f"Bearer {token}",
            "Content-Type": "application/json",
        })

    def _request(self, method: str, path: str, **kwargs) -> dict:
        url = f"{self.BASE_URL}{path}"
        response = self.session.request(method, url, **kwargs)
        response.raise_for_status()
        data = response.json()
        if data.get("error") == 1:
            raise Exception(data.get("message", "API Error"))
        return data

    # Links
    def list_links(self, page: int = 1, limit: int = 15) -> dict:
        return self._request("GET", f"/api/urls?page={page}&limit={limit}")

    def create_link(
        self,
        url: str,
        alias: Optional[str] = None,
        domain: str = "snipy.to",
        **kwargs,
    ) -> dict:
        body = {"url": url, "domain": domain, **kwargs}
        if alias:
            body["alias"] = alias
        return self._request("POST", "/api/url/add", json=body)

    def get_link(self, link_id: int) -> dict:
        return self._request("GET", f"/api/url/{link_id}")

    def update_link(self, link_id: int, **kwargs) -> dict:
        return self._request("PUT", f"/api/url/{link_id}/update", json=kwargs)

    def delete_link(self, link_id: int) -> dict:
        return self._request("DELETE", f"/api/url/{link_id}/delete")

    # QR Codes
    def list_qrs(self, page: int = 1) -> dict:
        return self._request("GET", f"/api/qrs?page={page}")

    def create_qr(self, name: str, url: str, **kwargs) -> dict:
        body = {"name": name, "url": url, **kwargs}
        return self._request("POST", "/api/qr/add", json=body)

    def download_qr(
        self, qr_id: int, fmt: str = "png", size: int = 300
    ) -> bytes:
        url = f"{self.BASE_URL}/api/qr/{qr_id}/download?format={fmt}&size={size}"
        response = self.session.get(url)
        response.raise_for_status()
        return response.content

    # Stats
    def get_link_stats(
        self,
        link_id: int,
        from_date: Optional[str] = None,
        to_date: Optional[str] = None,
    ) -> dict:
        params = {}
        if from_date:
            params["from"] = from_date
        if to_date:
            params["to"] = to_date
        return self._request(
            "GET", f"/api/url/{link_id}/stats", params=params
        )

    # Account
    def get_account(self) -> dict:
        return self._request("GET", "/api/account")
Usage example
from snipy_client import SnipyClient

client = SnipyClient("YOUR_TOKEN")

# Create a short link
result = client.create_link(
    url="https://example.com/page",
    alias="my-link",
    domain="snipy.to",
)
print("Created:", result["data"]["shorturl"])

# Get stats
stats = client.get_link_stats(result["data"]["id"])
print("Total clicks:", stats["data"]["totalClicks"])

# Download a QR code as PNG
qr = client.create_qr("My QR", "https://example.com")
png_data = client.download_qr(qr["data"]["id"], fmt="png", size=600)

with open("qr-code.png", "wb") as f:
    f.write(png_data)

cURL

Quick command-line examples for the most common operations.

Create a short link
curl -X POST https://api.snipy.com/api/url/add \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "alias": "demo"}'
List all links
curl -X GET "https://api.snipy.com/api/urls?page=1&limit=25" \
  -H "Authorization: Bearer YOUR_TOKEN"
Get link analytics
curl -X GET "https://api.snipy.com/api/url/456/stats?from=2026-01-01" \
  -H "Authorization: Bearer YOUR_TOKEN"
Create and download QR code
# Create
curl -X POST https://api.snipy.com/api/qr/add \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "My QR", "url": "https://example.com"}'

# Download PNG
curl -X GET "https://api.snipy.com/api/qr/78/download?format=png&size=400" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -o qr-code.png
Subscribe to webhooks
curl -X POST https://api.snipy.com/api/webhooks/subscribe \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourserver.com/webhook",
    "events": ["link.clicked", "link.created"],
    "secret": "whsec_your_secret"
  }'
Get account info
curl -X GET https://api.snipy.com/api/account \
  -H "Authorization: Bearer YOUR_TOKEN"

Community libraries

We welcome community-built libraries and integrations. If you have built an SDK or tool for Snipy, let us know and we will feature it here.

Submit your library via GitHub or email us at dev@snipy.com