Here’s how you can use the CodeQR TypeScript SDK to create a link and retrieve click analytics in timeseries format for it:
Copy
import { CodeQR } from "codeqr";// Initialize the CodeQR SDK with your API keyconst codeqr = new CodeQR({ token: process.env.CODEQR_API_KEY, // optional, defaults to CODEQR_API_KEY});// Create a new linkconst link = await codeqr.links.create({ url: "https://google.com",});console.log(link.shortLink); // e.g. https://codeqr.link/abc123// Get analytics for the linkconst analytics = await codeqr.analytics.retrieve({ link_id: link.id, groupBy: "timeseries", interval: "30d",});console.log(analytics); // e.g. [{ start: "2024-01-01", clicks: 100 }]