UNPKG

talisik-shortener

Version:

JavaScript/TypeScript client for Talisik URL Shortener - A privacy-focused URL shortening service

115 lines 3.44 kB
import { TalisikConfig, ShortenRequest, ShortenResponse, UrlInfo, Stats, RequestOptions } from "./types"; /** * Main client class for interacting with Talisik URL Shortener API * * @example * ```typescript * const client = new TalisikClient({ * baseUrl: 'https://api.talisik.com' * }); * * // Shorten a URL * const result = await client.shorten({ * url: 'https://example.com', * customCode: 'my-link' * }); * * // Get URL info * const info = await client.getUrlInfo('my-link'); * ``` */ export declare class TalisikClient { private config; constructor(config: TalisikConfig); /** * Shorten a URL * * @param request - The URL shortening request * @param options - Additional request options * @returns Promise that resolves to the shortened URL information * * @example * ```typescript * const result = await client.shorten({ * url: 'https://example.com', * customCode: 'my-custom-code', * expiresHours: 24 * }); * ``` */ shorten(request: ShortenRequest, options?: RequestOptions): Promise<ShortenResponse>; /** * Get information about a shortened URL * * @param shortCode - The short code to look up * @param options - Additional request options * @returns Promise that resolves to URL info or null if not found * * @example * ```typescript * const info = await client.getUrlInfo('abc123'); * if (info) { * console.log(`URL has been clicked ${info.clickCount} times`); * } * ``` */ getUrlInfo(shortCode: string, options?: RequestOptions): Promise<UrlInfo | null>; /** * Get overall statistics * * @param options - Additional request options * @returns Promise that resolves to usage statistics * * @example * ```typescript * const stats = await client.getStats(); * console.log(`Total URLs: ${stats.totalUrls}`); * ``` */ getStats(options?: RequestOptions): Promise<Stats>; /** * Get all shortened URLs for table display * * @param options - Additional request options * @returns Promise that resolves to array of URL records * * @example * ```typescript * const urls = await client.getAllUrls(); * console.log(`Found ${urls.length} URLs`); * ``` */ getAllUrls(options?: RequestOptions): Promise<any[]>; /** * Get the redirect URL for a short code (without following the redirect) * * @param shortCode - The short code * @returns The full redirect URL * * @example * ```typescript * const redirectUrl = client.getRedirectUrl('abc123'); * // Returns: https://api.talisik.com/abc123 * ``` */ getRedirectUrl(shortCode: string): string; /** * Expand a short code to get the original URL (follows redirect) * * @param shortCode - The short code to expand * @param options - Additional request options * @returns Promise that resolves to the original URL or null if not found * * @example * ```typescript * const originalUrl = await client.expand('abc123'); * // Returns: https://example.com * ``` */ expand(shortCode: string, options?: RequestOptions): Promise<string | null>; /** * Low-level request method */ private request; } //# sourceMappingURL=client.d.ts.map