import CodeQR from "@codeqr/ts";
// Initialize the CodeQR SDK with your API key
const codeqr = new CodeQR({
apiKey: process.env.CODEQR_API_KEY, // optional, defaults to CODEQR_API_KEY
});
// Create a new link
const link = await codeqr.links.create({
url: "https://google.com",
});
console.log(link.shortLink); // e.g. https://codeqr.link/abc123
// Get analytics for the link
const analytics = await codeqr.analytics.retrieve({
link_id: link.id,
groupBy: "timeseries",
interval: "30d",
});
console.log(analytics); // e.g. [{ start: "2024-01-01", clicks: 100 }]