flyn-sdk
v1.0.1
Published
Official TypeScript SDK for the Flyn.to link management API
Maintainers
Readme
Flyn SDK
Official TypeScript SDK for the Flyn.to link management API.
Install
npm install flyn-sdkQuick Start
import { Flyn } from 'flyn-sdk';
const flyn = new Flyn({ apiKey: 'flyn_sk_live_...' });
// Create a short link
const link = await flyn.links.create({
url: 'https://yourapp.com/launch',
domain: 'go.yourco.com',
slug: 'launch',
});
console.log(link.shortUrl); // → go.yourco.com/launchAPI Reference
new Flyn(config)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | — | Required. Your API key |
| baseUrl | string | https://www.flyn.to | API base URL |
| timeout | number | 10000 | Request timeout (ms) |
Links
flyn.links.create(options)
Create a new short link.
const link = await flyn.links.create({
url: 'https://example.com', // required
slug: 'my-link', // optional (auto-generated)
domain: 'go.yourco.com', // optional (default: flyn.to)
title: 'My Link', // optional
tags: ['campaign-q1'], // optional
password: 'secret', // optional
expiresAt: '2026-12-31T00:00:00Z', // optional
targeting: { // optional
device: { ios: 'https://apps.apple.com/...' },
geo: { DE: 'https://de.example.com' },
},
});flyn.links.list(options?)
List links with pagination and filtering.
const { data, pagination } = await flyn.links.list({
page: 1,
limit: 50,
status: 'active',
search: 'launch',
tag: 'campaign-q1',
sort: 'clicks',
order: 'desc',
});flyn.links.get(id)
Get a single link by ID.
const link = await flyn.links.get('link_abc123');flyn.links.update(id, options)
Update a link.
const link = await flyn.links.update('link_abc123', {
url: 'https://new-destination.com',
tags: ['updated'],
});flyn.links.delete(id)
Delete a link permanently (also deletes click analytics).
await flyn.links.delete('link_abc123');flyn.links.clicks(id, options?)
Get click analytics for a link.
const { data: clicks } = await flyn.links.clicks('link_abc123', {
page: 1,
limit: 100,
});
clicks.forEach(click => {
console.log(click.country, click.device, click.browser);
});Error Handling
import { Flyn, FlynError } from 'flyn-sdk';
try {
await flyn.links.create({ url: 'invalid' });
} catch (err) {
if (err instanceof FlynError) {
console.error(err.message); // "Invalid URL"
console.error(err.status); // 400
console.error(err.code); // "HTTP_400"
}
}Get Your API Key
- Log in to flyn.to/settings
- Go to API Keys
- Click Create Key
License
MIT
