Active: SDKEasy to start24/7 SupportEasy to integrate
Node.js available
Node.js SDK for SkyBrance auth and link management.
The SDK ships as a pair of packages: one client for authenticated requests and one link-shortener wrapper that handles create, update, fetch list, upload, and delete flows.
Install
npm install @skybrance/auth @skybrance/link-shortener
Bootstrap
import { SkyBranceClient } from "@skybrance/auth";
import { SkyBranceLinkShortener } from "@skybrance/link-shortener";
const client = new SkyBranceClient({
apiKeyId: process.env.API_KEY_ID,
apiKeySecret: process.env.API_KEY_SECRET,
});
const links = new SkyBranceLinkShortener(client);
const created = await links.create({
url: "https://example.com",
title: "Example",
});Supported methods
verify()
Check whether the credentials are valid.
create(params)
Create a shortened link.
update(id, params)
Update an existing link.
getById(id, numberOfPastDays)
Fetch link details with analytics history.
uploadOgImage(id, { contentType })
Generate a signed OG image upload URL.
deleteById(id)
Delete a link.
getList(filters)
Return a paginated list of links.
Example usage
const created = await links.create({
url: "https://example.com",
title: "Example",
});
const details = await links.getById(created._id, 7);
const upload = await links.uploadOgImage(created._id, { contentType: "image/jpeg" });
await links.deleteById(created._id);API Examples & Parameters
verify()
Check whether the configured credentials are valid.
// signature: verify(): Promise<VerifyResponse>
await client.verify();
// response shape
{
status: string;
message: string;
isValid: boolean;
}create(params)
Creates a new short link. Parameters accepted by the SDK:
urlaliasexpiryisPasswordProtectedpasswordtitledescriptionexpiryTitleexpiryMessageexpiryUrl
// signature: create(params: CreateLinkParams): Promise<ShortLinkData>
const newLink = await links.create({
url: 'https://www.youtube.com/',
title: 'My Video',
description: 'Optional description',
alias: 'my-video', // optional custom alias
expiry: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // optional
isPasswordProtected: false,
});
console.log(newLink._id, newLink.shortUrl);update(id, params)
Updates an existing link. Parameters accepted by the SDK:
urlaliasexpiryisPasswordProtectedpasswordtitledescriptionexpiryTitleexpiryMessageexpiryUrl
// signature: update(id: string, params: UpdateLinkParams): Promise<ShortLinkData>
const updated = await links.update(newLink._id, {
title: 'Updated title',
description: 'Updated description',
});
console.log(updated.title);getById(id, numberOfPastDays)
Fetch a link and optional analytics for the last N days.
// signature: getById(id: string, numberOfPastDays?: number): Promise<LinkByIdData> const details = await links.getById(newLink._id, 7); // analytics for past 7 days console.log(details.link.shortUrl, details.analytics.totalClicks);
uploadOgImage(id, { contentType })
Generates a signed upload URL and public URL for the link's OG image.
// signature: uploadOgImage(id: string, params: OgImageUploadParams): Promise<OgImageUploadData>
const og = await links.uploadOgImage(newLink._id, { contentType: 'image/png' });
// Use og.uploadUrl to PUT the binary, og.publicUrl is the eventual public URL
console.log(og.publicUrl);deleteById(id)
Deletes the link by id.
// signature: deleteById(id: string): Promise<DeleteLinkResponse>
await links.deleteById(newLink._id);
console.log('Deleted');getList(filters)
Retrieve a paginated list of links. Filters are optional.
// signature: getList(filters?: ListLinksFilters): Promise<PaginatedLinkResponse>
const list = await links.getList({ page: 1, limit: 20, search: 'youtube' });
console.log(list.pagination.total, list.data.length);